[Python] 纯文本查看 复制代码 import re
import requests
def get_small_red_book(url):
commom_header = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"}
resp = requests.get(url, headers=commom_header)
result = re.search('og:title.*="(.*?)">', resp.text).group(1)
print(result)
pic_url = re.search('og:image.*="(.*?)">', resp.text).group(1)
print(pic_url)
if __name__ == '__main__':
url = 'http://xhslink.com/62c3kz'
get_small_red_book(url) |