import time,os
from lxml import etree
from excel_wirte_utils.wirte_to_excel import write_to_excel,write_to_excel_append
import xlrd
from xlutils.copy import copy
import requests
import xlwt
from selenium import webdriver
def get_xpath_by_selenium(url):
#1创建一个dirver
driver = webdriver.PhantomJS()
#2请求url
driver.get(url)
#3等待
time.sleep(1)
#4获取页面源代码
html_str = driver.page_source
return html_str
def get_text(text):
if text:
return text[0]
return ''
# def write_to_excel_append(infos,filename):
# #要写如数据的行数
# index = len(infos)
# #打开工作薄
# work_book = xlrd.open_workbook(filename)
# #获取工作薄中所有sheet表单
# sheets = work_book.sheet_names()
# #获取第一个表单
# work_sheet = work_book.sheet_by_name(sheets[0])
# #获取已经写入的行数
python爬虫--爬取豆瓣读书----内容数据
最新推荐文章于 2024-07-08 15:33:13 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)