[英]Beginner Python Webscraping
我是python的初学者。 我正在做一个网页抓取项目。 在项目中,我想从剑桥词典中查找一些单词的含义和词性并将它们导出到 excel 中。
这是我的代码:
pip install bs4
pip install requests
from bs4 import BeautifulSoup
import requests
headers = {"User-Agent" : "xxxxxxx"}
r=requests.get('https://dictionary.cambridge.org/dictionary/english/happy', headers=headers)
soup = BeautifulSoup(r.text,'html.parser')
POS = soup.find_all("span", class_="pos dpos")
print(POS)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.