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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:50:26+00:00 2026-06-02T18:50:26+00:00

Im trying to first grab all the links from a page, when get the

  • 0

Im trying to first grab all the links from a page, when get the URL for the “next” button and keep looping until there are no more pages. Been trying to get a nested loop going to achieve that but for some reason BeautifulSoup does never parse the second page.. only the first one and then stops..

Hard to explain but here is the code should be easier to understand what i am trying to explain 🙂

#this site holds the first page that it should start looping on.. from this page i want to reach page 2, 3, etc.
   webpage = urlopen('www.first-page-with-urls-and-next-button.com').read()

soup = BeautifulSoup(webpage)

for tag in soup.findAll('a', { "class" : "next" }):

    print tag['href']
    print "\n--------------------\n"


#next button is relative url so append it to main-url.com
    soup = BeautifulSoup('http://www.main-url.com/'+ re.sub(r'\s', '', tag['href']))

#for some reason this variable only holds the tag['href']
    print soup

    for taggen in soup.findAll('a', { "class" : "homepage target-blank" }):
        print tag['href']

        # Read page found
        sidan = urlopen(taggen['href']).read()

# get title
        Titeln = re.findall(patFinderTitle, sidan)

        print Titeln

Any ideas? So sorry for poor english, i hope i will not get hammered 🙂 Please ask if i have explained it to poorly i will do my best to explain some more. Oh and i am new to Python – as of today (as you might have figured:)

  • 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-02T18:50:27+00:00Added an answer on June 2, 2026 at 6:50 pm

    If you call urlopen on the new url and pass the resulting file object to BeatifulSoup I think you’ll be all set. That is:

    wepage = urlopen(http://www.main-url.com/'+ re.sub(r'\s', '', tag['href']))
    soup = BeautifulSoup(webpage)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a list of PDF links from different websites. First I'm
I'm trying to use jQuery to get all the paragraphs before the first h2
I'm basically trying to get all touch event data from something like a system
I'm trying to grab all NA phone numbers from a CSV file. The numbers
I'm trying to grab all the URLs of my Facebook photos. I first load
I am trying to grab only the first instance of an element from an
I was trying for the first time to read data from a file, a
I am trying to grab a number from a text box entry, convert it
I'm trying to grab multiple rows from SQL Server and then manipulate them in
What I'm trying to do is grab entries from an updates table in a

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.