维普作者简介

#!/usr/bin/python
#encoding=utf-8
__author__ = 'Administrator'
from  bs4 import  BeautifulSoup
import selenium
import sys
import urllib
import requests
import time
import re

if __name__ == "__main__":
    import os
    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait

    headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0'}

    chromedriver = "/home/henson/Documents/pycharm/webdriver/chromedriver"
    os.environ["webdriver.chrome.driver"] = chromedriver
    driver = webdriver.Chrome(chromedriver)
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
    driver.get('http://qikan.cqvip.com/writer/writersearch.aspx?from=writer_writersearch&key=U%3D%E5%A4%A7%E6%B0%94%E6%B1%A1%E6%9F%93')
    currentURL=driver.current_url
    time.sleep(2)
    #currentURL=driver.current_url
    urlList=[]
    localDir = '/home/henson/Downloads/paper'


   # bbc=driver.find_element_by_xpath("//*[@id='body']/div/div[3]/div[3]/dl[1]/dt/a[@class='title btnTitle']").click()
   # print(bbc)

    k=1
    for j in  range (1,2):
        driver.find_element_by_xpath("//*[@id='body']/div/div[3]/div[3]/dl["+str(j)+"]/dt/a[@class='title btnTitle']").click()
        time.sleep(6)
        currentURL = driver.current_url
       # print(currentURL)
       # print("NO."+str(j)+"页")
        author= driver.find_element_by_xpath(
                    "//*[@id='body']/div[1]/dl/dt/h1").text
        cites = driver.find_element_by_xpath(
                    "//*[@id=’body‘]/div[1]/dl/dd[1]").text
        mechanism = driver.find_element_by_xpath(
                    "//*[@id=’body‘]/div[1]/dl/dd[3]/span").text
        theme = driver.find_element_by_xpath("//*[@id='body']/div[1]/dl/dd[4]").text
        print(author)
        print(cites)
        print(mechanism)
        print(theme)



"""
分开获取
j(1-21)  :  k=1 ,    k=11 
j(19-n)  :  k=12,    k=10 
"""

取的xpath出不来的要么是自己的问题,没有耐心细心,,要么是加载时间不够。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值