国内高匿免费代理 爬虫代码

2022-07-13 20:26:12 浏览数 (1)

只爬了ip

代码语言:javascript复制
import requests
import parsel
import base64
import re

res = requests.get('http://ip.yqie.com/proxygaoni/index.htm')
res.encoding = 'utf-8'
for i in parsel.Selector(res.text).xpath("//tr/td[2]").extract():
    print(base64.b64decode(re.findall(f'window.atob("(.*?)")', i)[0]).decode())

新增一个lxml的xpath版本

代码语言:javascript复制
import base64
import re

import requests
from lxml import etree

res = requests.get('http://ip.yqie.com/proxygaoni/index.htm')
res.encoding = 'utf-8'
for i in etree.HTML(res.text).xpath('//tr/td[2]/script'):
    print(base64.b64decode(re.findall(f'window.atob("(.*?)")', i.text)[0]).decode())

0 人点赞