我正在尝试抓取一个网站,但是,我无法完成代码,以便我可以一次插入多个 URL。目前,该代码一次只能使用一个 URL,
当前代码是:
import requests
from bs4 import BeautifulSoup
import lxml
import pandas as pd
from urllib.request import urlopen
from urllib.error import HTTPError
from urllib.error import URLError
from bs4 import BeautifulSoup
try:
html = urlopen("http://google.com")
except HTTPError as e:
print(e)
except URLError:
print("error")
else:
res = BeautifulSoup(html.read(),"html5lib")
tags = res.findAll("div", {"itemtype": "http://schema.org/LocalBusiness"})
title = res.title.text
print(title)
for tag in tags:
print(tag)
有人可以帮我进行修改,以便我可以插入这样的东西吗?
html = urlopen ("url1, url2, url3")