import requests
from bs4 import BeautifulSoup
def open_url(url):
head = {"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}
html = requests.get(url,headers = head).text
soup = BeautifulSoup(html,"html.parser")
title = soup.find(id = "activity-name")
print(title.text)
data = soup.find_all("section")
text = []
for i in data:
if i.text not in text:
text.append(i.text)
for i in text:
print(" " + i ,end = "\n\n")
if __name__ == "__main__":
url = "https://mp.weixin.qq.com/s/mBgzrvvODAVn2jFgQjC8-A"
open_url(url)
|