代码是这样的,要如何改动啊
import requests from pyquery import PyQuery as pq from urllib.parse import urlencode import re
def dizhi(): headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3573.0 Safari/537.36'} data = { 'q': '微信群', 'typeall': '1', 'suball': '1', 'timescope': 'custom:2018 - 12 - 20 - 0: 2018 - 12 - 22 - 0', 'Refer': 'g' } url = 'https://s.weibo.com/weibo/%25E5%25AE%259D%25E5%25A6%2588%25E7%25BE%25A4?' + urlencode(data) wangzhi = requests.get(url,headers = headers) return wangzhi.text
def jiexi(html): doc = pq(html) item = doc('.m3 li') print(item('img').attr('src'))
def main(): html = dizhi() jiexi(html)
if name == 'main': main()
打印结果:
//ww4.sinaimg.cn/thumb150/475ee913ly1fydb7js7inj20orcmvx6q.jpg