1. 复杂的js逆向的,不想破解掉头发
最简单的方式是模拟浏览器,做 python 的 很快想到 selenium的webdriver:打开Chrome浏览器来模拟,这种方式网上的例子比较多,仿写一个比较容易,代码如下:
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
# 指定驱动
driver_path = "chromedriver.exe"
#driver = webdriver.Chrome(driver_path, options = options)
options = webdriver.ChromeOptions()
PROXY = "xx.xx.xx.xx:xxxx" # IP:PORT or HOST:PORT
options.add_argument('--proxy-server=%s' % PROXY)
driver = webdriver.Chrome(driver_path, options=options)
url = 'https://www.gunviolencearchive.org/last-72-hours'
driver.get(url)
time.sleep(600)