实习僧字体反爬

F12进入,发觉数字部分都用框代替,推测为字体反爬。
实习僧字体反爬_第1张图片

ctr+u,查看源代码。推测浏览器的数字与源代码一一对应。刷新网页,发觉这些加密的数字不变。数字加密居然是静态的。数字就只有10个,多看几个相关界面,就可以全部数字都推测出来。

实习僧字体反爬_第2张图片
:0

:1

:2

:3

:4

:5

:6

:7

:8

:9

完整代码如下:

import time
t1=time.time()
import requests
import re
from fontTools.ttLib import TTFont
from lxml import etree
from aip import AipOcr  #pip install baidu-aip
url = "https://www.shixiseng.com/intern/inn_h6waqz0yrsyt?pcm=pc_SearchList"
response = requests.get(url=url)
response.encoding = 'utf-8'
html_data = response.text
f={
     
"":"0",
"":"1",
"":"2",
"":"3",
"":"4",
"":"5",
"":"6",
"":"7",
"":"8",
"":"9",
}
for i,j in f.items():
    html_data=html_data.replace(i,j)
x1='/html/body/div[1]/div[2]/div[1]/div[2]/span[1]/text()' #job_date
x2='/html/body/div[1]/div[2]/div[1]/div[3]/span[1]/text()' #job_money
x3='/html/body/div[1]/div[2]/div[1]/div[3]/span[4]/text()' #job_week
x4='/html/body/div[1]/div[2]/div[1]/div[3]/span[5]/text()' #job_time
x5='/html/body/div[1]/div[2]/div[2]/div[1]/div[2]/div[3]/text()' #截止日期
selector = etree.HTML(html_data) 
a1=selector.xpath(x1)[0]
print(a1)
a2=selector.xpath(x2)[0]
print(a2)
a3=selector.xpath(x3)[0]
print(a3)
a4=selector.xpath(x4)[0]
print(a4)
a5=selector.xpath(x5)[0]
print(a5)

运行结果如下:
2021-01-21 17:32:46
120-150/天
5天/周
实习3个月
截止日期:2021-02-18

成功反反爬了。

你可能感兴趣的:(xpath,python,html,爬虫)