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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:48:21+00:00 2026-05-15T12:48:21+00:00

Edit: Just for clarification I am using python, and would like to do this

  • 0

Edit: Just for clarification I am using python, and would like to do this within python.

I am in the middle of collecting data for a research project at our university. Basically I need to scrape a lot of information from a website that monitors the European Parliament. Here is an example of how the url of one site looks like:

http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A7-2010-0190&language=EN

The numbers after the reference part of the address refers to:
A7 = Parliament in session (previous parliaments are A6 etc.),
2010 = year,
0190 = number of the file.

What I want to do is to create a variable that has all the urls for different parliaments, so I can loop over this variable and scrape the information from the websites.

P.S: I have tried this:

number = range(1,190,1) 

   for i in number: 
       search_url = "http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A7-2010-" + str(number[i]) +"&language=EN" 

      results = search_url 
      print results

but this gives me the following error:
Traceback (most recent call last):
File “”, line 7, in
IndexError: list index out of range

  • 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-05-15T12:48:21+00:00Added an answer on May 15, 2026 at 12:48 pm

    If I understand correctly, you just want to be able to loop over the parliments?

    i.e. you want A7, A6, A5…?

    If that’s what you want a simple loop could handle it:

    for p in xrange(7,0, -1):
        parliment = "A%d" % p
        print p
    

    for the other values similar loops would work just as well:

    for year in xrange(2010, 2000, -1):
        print year
    
    for filenum in xrange(100,200):
        fnum = "%.4d" % filenum
        print fnum
    

    You could easily nest your loops in the proper order to generate the combination(s) you need. HTH!

    Edit:

    String formatting is super useful, and here’s how you can do it with your example:

    # Just create a string with the format specifier in it: %.4d - a [d]ecimal with a
    # precision/width of 4 - so instead of 3 you'll get 0003
    search_url = "http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A7-2010-%.4d&language=EN"
    
    # This creates a Python generator. They're super powerful and fun to use,
    # and you can iterate over them, just like a collection.
    # 1 is the default step, so no need for it in this case
    for number in xrange(1,190):   
        print search_url % number
    

    String formatting takes a string with a variety of specifiers – you’ll recognize them because they have % in them – followed by % and a tuple containing the arguments to the format string.

    If you want to add the year and parliment, change the string to this:
    search_url = "http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=A%d-%d-%.4d&language=EN"

    where the important changes are here:
    reference=A%d–%d–%.4d&language=EN

    That means you’ll need to pass 3 decimals like so:

    print search_url % (parliment, year, number)

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

Sidebar

Ask A Question

Stats

  • Questions 441k
  • Answers 441k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes it is possible that you can download your content… May 15, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer conditions => ["item_id == ?", item.id should be conditions =>… May 15, 2026 at 5:30 pm
  • Editorial Team
    Editorial Team added an answer This link contains information on using right to left languages… May 15, 2026 at 5:30 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.