Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8322425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:23:05+00:00 2026-06-08T23:23:05+00:00

I suspect this is a trivial query but hope someone can help me with

  • 0

I suspect this is a trivial query but hope someone can help me with a query I’ve got using lxml in a scraper I’m trying to build.

https://scraperwiki.com/scrapers/thisisscraper/

I’m working line-by-line through the tutorial 3 and have got so far with trying to extract the next page link. I can use cssselect to identify the link, but I can’t work out how to isolate just the href attribute rather than the whole anchor tag.

Can anyone help?

def scrape_and_look_for_next_link(url):
    html = scraperwiki.scrape(url)
    print html
    root = lxml.html.fromstring(html) #turn the HTML into lxml object
    scrape_page(root)
    next_link = root.cssselect('ol.pagination li a')[-1]

    attribute = lxml.html.tostring(next_link)
    attribute = lxml.html.fromstring(attribute)

    #works up until this point
    attribute = attribute.xpath('/@href')
    attribute = lxml.etree.tostring(attribute)
    print attribute
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:23:07+00:00Added an answer on June 8, 2026 at 11:23 pm

    CSS selectors can select elements that have an href attribute with eg. a[href] but they can not extract the attribute value by themselves.

    Once you have the element from cssselect, you can use next_link.get('href') to get the value of the attribute.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help explain this? I am using the Populator and Faker gems to
I suspect this has been asked before, but can't seem to find a question
I suspect this has already been answered somewhere, but I can't find it, so...
I suspect this question will seem too... silly, but I'm trying to get my
I am not sure if this is a unity bug but can anyone help
I suspect this applies to general ASP.Net too but I am not sure. If
I suspect this is impossible, but thought I'd ask. Say I have a class
I am new to both DBs and Rails (using 3.2), and I suspect this
I suspect I am going to feel really stupid after posting this but here
I suspect this is a very trivial question. I'm writing a PHP script to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.