我要抓取如下网站的信息:http://www.cninfo.com.cn/information/companyinfo_n.html?fulltext?szcn300027,想获取里面所有文件的链接,然后下载下来。
这个网页时动态加载的,在源代码里面没有链接,所以我尝试用selenium+phantomjs的方法来获取内容,但是提示说找不到,想问问大家问题在哪儿?
代码如下:
# -*-coding:utf8 -*-
import requests
from selenium import webdriver
import time
class CninfInfo:
def __init__(self):
self.url = "http://www.cninfo.com.cn/cninfo-new/index"
self.driver = webdriver.PhantomJS()
def GetInfo(self):
url = "http://www.cninfo.com.cn/information/companyinfo_n.html?fulltext?szcn300027"
time.sleep(10)
names = self.driver.find_elements_by_xpath("//ul[@class='ct-line']/li/div[@class='g3']/dd/span[@class='d1']/a")
for name in names:
print("名称为:",name.text)
if __name__ == "__main__":
CI = CninfInfo()
a = CI.GetInfo()
这仅仅是一个post提交,为什么要搞得这么复杂