引入必要库:
from selenium import webdriver
import requests
import re
import time
import pandas as pd
1.批量下载单个页面上的PDF文件
#获得源代码
CHROME_DRIVER = 'C:\Program Files\Google\Chrome\Application//chromedriver' #chromedriver的目录
chrome_options = webdriver.ChromeOptions()
#chrome_options.add_argument('--headless')#不显示浏览器窗口
driver = webdriver.Chrome(executable_path=CHROME_DRIVER,options = chrome_options)
url = "http://www.sse.com.cn/disclosure/credibility/supervision/inquiries/"
driver.get(url)
time.sleep(3)
data = driver.page_source
print(data)
#源代码进行解析获取内容
p_title = '<tr><td class="codeNameWidth"><span>.*?</span></td><td class="codeNameWidth"><span>.*?</span></td><td class="text-nowrap">.*?</td><td><span class="table_typewrap">.*?</span></td><td><a class="table_titlewrap" href=".*?" target="_blank">(.*?)</a></td></tr>'
p_href = '<tr><td class="codeNameWidth"><span>.*?</span></td><td class="codeNameWidth"><span>.*?</span></td><td class="text-nowrap">.*?</td><td><span class="table_typewrap">.*?</span></td><td><a class="table_titlewrap" href="(.*?)