##我的网盘/博客素材/爬取药监
#爬取药监总局化妆品生产许可企业名称
from selenium import webdriver
from time import sleep
from lxml import etree
url = 'http://scxk.nmpa.gov.cn:81/xk/'
bro = webdriver.Chrome(executable_path='./chromedriver')
bro.get(url)
page_text_list = [] #每一页页面源码数据
sleep(1)
#捕获当前页面源码数据
page_text = bro.page_source
page_text_list.append(page_text)
#点击下一页
for i in range(3):
next_page = bro.find_element_by_xpath('//*[@id="pageIto_next"]')
next_page.click()
sleep(1)
page_text_list.append(bro.page_source) #获取每一页页面源码数据
for page_text in page_text_list: #对每一页页面源码数据进行解析
tree = etree.HTML(page_text)
li_list = tree.xpath('//*[@id="gzlist"]/li')
for li in li_list:
name = li.xpath('./dl/@title')[0]
time = li.xpath('./em/@title')[0]
print(name)
print(time)
sleep(1)
bro.quit()
暂无评论