You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python/README.md

14 lines
458 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# python
from bs4 import BeautifulSoup
import requests
res = requests.get('https://mp.weixin.qq.com/s/K0u_qPFQtWuH4hk5K2xWfQ')#新闻的网址
res.encoding = res.apparent_encoding
soup = BeautifulSoup(res.text, 'html')#使用html5lib样式来解析网页看不懂没关系
print(soup)#查看页面源代码
data = soup.select('p')#元素选择器
text=''
for p in data:
text += p.text.strip()
print(text)
#到此微信网页内容信息爬取完毕