Question

i am trying to request multi urls using requests.get this is what i started with

for number in range(1,10):
    page =requests.get('http://google.com/page'+str(number),'http://yahoo.com/page'+str(number))

but what i get is an error TypeError: get() takes exactly 1 argument (2 given)

i have also tried this

url=['','http://google.com/page','http://yahoo.com/page']

for number in range(1,10):
    page = requests.get(url[number]+str(number))

this gives me

IndexError: list index out of range
Was it helpful?

Solution

urls = ['http://google.com/page','http://yahoo.com/page']

for url in urls:
    for number in range(1,10):
        page = requests.get(url+str(number))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top