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

  • Home
  • SEARCH
  • 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 9258391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:23:25+00:00 2026-06-18T12:23:25+00:00

I am scraping data from following html structure from 30-40 webpages like these https://www.o2.co.uk/shop/tariffs/sony/xperia-z-purple/

  • 0

I am scraping data from following html structure from 30-40 webpages like these https://www.o2.co.uk/shop/tariffs/sony/xperia-z-purple/ :

    <td class="monthlyCost">£13<span>.50</span></td>
              <td class="phoneCost">£479.99</td>
              <td><span class="lowLight">24 Months</span></td>
    <td>50</td>
    <td>Unlimited</td>
    <td class="dataAllowance">100MB</td>
    <td class="extras">

I am indexing to scrape data present under td tags having no class like 50 & Unlimited which corresponds to Minutes and texts column in the dataset. Code which I am using is:

        results       = tariff_link_soup.findAll('td', {"class": None})
        minutes = results[1]
        texts = results[2]
        print minutes,texts

All these 30-40 webplinks are present on https://www.o2.co.uk/shop/phones/ webpage, I am finding those links on this webpage accessing them and then reaching this desired webpage, all these final device webpages follow same structure.

Problem: I was hoping to get only minutes and text values which are like 50 & Unlimited, 200 & Unlimited and are present at 2nd and 3rd index for all webpages. Still I am getting some other values when I am printing the data for eg. 500MB, 100MB which are values under dataAllowance class and td tag. I am using class as None attribute but still not able to get required data. I checked html structure and it was consistent across pages.

Please help me in solving this issue as I am not able to fathom reason for this anomaly.

Update: Entire Python code which I am using:

urls  =  ['https://www.o2.co.uk/shop/phones/',
          'https://www.o2.co.uk/shop/phones/?payGo=true']

plans =  ['Pay Monthly','Pay & Go']
for url,plan in zip(urls,plans):

    if plan == 'Pay Monthly':
        device_links = parse().direct_url(url,'span', {"class": "model"})

        for device_link in device_links:
            device_link.parent['href'] = urlparse.urljoin(url, device_link.parent['href'])            
            device_link_page           = urllib2.urlopen(device_link.parent['href'])
            device_link_soup           = BeautifulSoup(device_link_page)

        dev_names = device_link_soup.find('h1')
        for devname in dev_names:

            tariff_link = device_link_soup.find('a',text = re.compile('View tariffs'))

            tariff_link['href'] = urlparse.urljoin(url, tariff_link['href'])

            tariff_link_page    = urllib2.urlopen(tariff_link['href'])
            tariff_link_soup    = BeautifulSoup(tariff_link_page)
            dev_price     = tariff_link_soup.findAll('td', {"class": "phoneCost"})
            monthly_price = tariff_link_soup.findAll('td', {"class": "monthlyCost"})
            tariff_length = tariff_link_soup.findAll('span', {"class": "lowLight"})
            data_plan     = tariff_link_soup.findAll('td', {"class": "dataAllowance"})
            results       = tariff_link_soup.xpath('//td[not(@class)]')
            print results[1].text
            print results[2].text
  • 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-18T12:23:26+00:00Added an answer on June 18, 2026 at 12:23 pm

    I finally used following code to solve my problem:

        for row in tariff_link_soup('table', {'id' : 'tariffTable'})[0].tbody('tr'):                                                                                                                                                               
            tds = row('td')                                                                                                                                                   
            #print tds[0].text,tds[1].text,tds[2].text,tds[3].text,tds[4].text,tds[5].text
            monthly_prices = unicode(tds[0].text).encode('utf8').replace("£","").replace("FREE","0").replace("Free","0").strip()
            dev_prices     = unicode(tds[1].text).encode('utf8').replace("£","").replace("FREE","0").replace("Free","0").strip()
            tariff_lengths = unicode(tds[2].text).encode('utf8').strip()
            minutes        = unicode(tds[3].text).encode('utf8').strip()
            texts          = unicode(tds[4].text).encode('utf8').strip()
            data           = unicode(tds[5].text).encode('utf8').strip()
            device_names   = unicode(dev_names).encode('utf8').strip()
    

    I am accessing the required data row by row here, using the tabular structure in which data is present. I am taking all elements present in a row and assigning names to those which are required in my data.

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

Sidebar

Related Questions

I'm scraping data from third party sites using an html parser and then inserting
Background : With a Python Script, I scraping data (html) from a Website and
I am scraping data from web site using my java application and want to
I'm scraping data from the web, and I have several processes of my scraper
I have been using HTML Parser to scrapping data from websites and stripping html
I am regularly scraping and storing some dated data from a website into a
I am scraping some data from a website and I am able to do
I am doing a little data scraping, There are 3 types of file from
i have the following script i am using to scrap data from my uni
Need help I am scraping data from this website which has a form that

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.