具体代码如下:
import requests import re headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36'}#创建头部信息 url = 'https://v.sogou.com/vertical/2w65l6nv47j3bnhtzcv4hyvx2g45xp5u.html' resp = requests.get(url,headers=headers) info = re.findall(r'<a href=".*" uigs=".*" target="_blank">(.*)</a>',resp.text) print( info ) lst=[] #用于存储拼接后的url for item in info: lst.append('https:'+item) #这样哪些连接的颜色就变了
比较简单,稍微练练手