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 8043201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:49:47+00:00 2026-06-05T04:49:47+00:00

I am trying to do something which appeared to be simple…I am trying to

  • 0

I am trying to do something which appeared to be simple…I am trying to scrape company names of reuters list from this link:

http://www.reuters.com/finance/markets/index?symbol=us!spx&sortBy=&sortDir=&pn=

however, I just can’t access the company names! Really, after playing around with a lot of xpath queries, I have problems accessing the table. I am trying to grab the names such as “3M company” and “Abbott Laboratories”

Here are snippets of code I have used:

scrape = []
companies =[]
import lxml
import lxml.html
import lxml.etree

urlbase = 'http://reuters.com/finance/markets/index?symbol=us!spx&sortBy=&sortDir=&pn='
for i in range(1:18):
    url = urlbase+str(i)
    content = lxml.html.parse(url)
    item = content.xpath('XPATH HERE')
    ticker = [thing.text for thing in item]

Here are the xpaths i have been playing with:

'//*[@id="topContent"]/div/div[2]/div[1]/table/tr[2]/td[1]/a'
'//*[@id="topContent"]/div/div[2]/div[1]/table/tbody/tr[2]/td[1]/a
'/html/body/div[3]/div[3]/div/div[2]/div/table/tbody/tr[3]/td/a'
'/html/body/div[3]/div[3]/div/div[2]/div/table/tr[3]/td/a'

I have tried accessing that one particular table through:
'//table[@class="dataTable sortable"]', but have not had any luck

can anyone help? I feel like this is something that someone who knows what they are doing will be able to fix rather quickly
THANKS!

  • 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-05T04:49:49+00:00Added an answer on June 5, 2026 at 4:49 am

    The page you’re trying to scrape has a form inside the table. The correct xpath should be '//table[@class="dataTable sortable"]/form/tr/td[1]/a'

    Also, you probably have a typo in your code, it should be range(1,18) instead of range(1:18). Here’s the final code that works on my side:

    scrape = []
    companies =[]
    import lxml
    import lxml.html
    import lxml.etree
    
    urlbase = 'http://reuters.com/finance/markets/index?symbol=us!spx&sortBy=&sortDir=&pn='
    for i in range(1,18):
        url = urlbase+str(i)
        content = lxml.html.parse(url)
        item = content.xpath('//table[@class="dataTable sortable"]/form/tr/td[1]/a')
        ticker = [thing.text for thing in item]
        print ticker
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to do something which I thought would be fairly simple. Get IIS
I'm trying to do something which is probably very simple, I have a directory
I'm kinda stuck with something which must be appalingly simple. I'm trying to write
I'm trying to solve a problem which is something like this: I'm given n
I'm trying something like this: Foo & operator=(Foo & to, const Bar &from); But
Im trying something like this (which doesnt compile): struct mystruct { somestruct arr[4]; mystruct(somestruct
Ok I'm trying to do something which should be very simple in my mind
this is my first post, and it covers something which I've been trying to
I'm trying to do something which should be very simple...I have a site with
I'm trying to do something which seems simple. I want to have a map

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.