Tdakers
Tdakers

Reputation: 43

How to pull multiple URLs in a single Python Call

I am trying to pull multiple websites in the same Python call. I cannot get it to work correctly and have had to put in each call individually.

I have already tried doing the following:

URL = ['https://sc2replaystats.com/replay/playerStats/10758933/83445': https://sc2replaystats.com/replay/playerStats/10758969/83445]
content = requests.get(URL)

soup = BeautifulSoup(content.text, 'html.parser')

contentTable  = soup.find('table', "table table-striped table-condensed")
rows = contentTable.find_all('span', "blizzard_icons_single") 
print (rows)

Here is my current code:

from bs4 import BeautifulSoup # BeautifulSoup is in bs4 package 
import requests

URL = 'https://sc2replaystats.com/replay/playerStats/10758969/83445'
content = requests.get(URL)

soup = BeautifulSoup(content.text, 'html.parser')

contentTable  = soup.find('table', "table table-striped table-condensed")
rows = contentTable.find_all('span', "blizzard_icons_single") 
print (rows)

Upvotes: 0

Views: 174

Answers (1)

blues
blues

Reputation: 5195

You can't combine multiple http requests into one. You can however do them one after the other. Maybe check the python documentation on lists and loops.

urls = ['http://example.com', 'http://example.org']
for url in urls:
    content = requests.get(url)
    print(content)

Upvotes: 1

Related Questions