我有我想要用来获取数据的URL的列表。我可以为一个url执行以下操作:
URL list = ['https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/4722/',
'https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/6318/'
from bs4 import BeautifulSoup
import requests
url = "https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/4479/"
page = requests.get(url)
soup = BeautifulSoup(page.text, "html.parser")
info = soup.find_all("dl", {'class':'c-description-list c-description-list--striped'})
comp_info = pd.DataFrame()
cleaned_id_text = []
for i in info[0].find_all('dt'):
cleaned_id_text.append(i.text)
cleaned_id__attrb_text = []
for i in info[0].find_all('dd'):
cleaned_id__attrb_text.append(i.text)
df = pd.DataFrame([cleaned_id__attrb_text], column = cleaned_id_text)
但我不知道如何对几个URL执行此操作,并将数据附加到dataframe中。每个URL都描述了课程描述,所以我想创建一个数据框,其中包含所有URL的所有数据。。。如果我能在dataframe中添加URL作为单独的列,那就太好了
按用户请求更新:
相关问题 更多 >
编程相关推荐