分类: Python
Python 配合openpyxl模块 把抓取到的数据写入xlsx EXCEL表格
import requests,openpyxl # 创建工作薄 wb=openpyxl.Workbook() # 获取工作薄的活动表 sheet=wb.active # 工作表重命名 sheet.title=’lyrics’ sheet[‘A1′] =’歌曲名’ # 加表头,给A1单元格赋值 sh […]
2019-12-12Python# 直接运行代码就好 from bs4 import BeautifulSoup import requests # 引用requests模块 url = ‘https://c.y.qq.com/soso/fcgi-bin/client_search_cp’ headers = { ‘origin’ […]
2019-12-12Python# 直接运行代码就好 import requests # 引用requests模块 url = ‘https://c.y.qq.com/soso/fcgi-bin/client_search_cp’ headers = { ‘origin’:’https://y.qq.com’, # 请求来源,本案 […]
2019-12-12Pythonimport requests #发出请求,并把返回的结果放在变量res中 res = requests.get(‘https://localprod.pandateacher.com/python-manuscript/crawler-html/exercise/HTTP%E5%93%8D%E5% […]
2019-12-11Pythonfrom gevent import monkey #从gevent库里导入monkey模块。 monkey.patch_all() #monkey.patch_all()能把程序变成协作式运行,就是可以帮助程序实现异步。 import gevent,time,requests #导入gevent、 […]
2019-12-11PythonPython 自动抓取天气预报并且每天自动发送天气到指定邮箱
import requests import smtplib import schedule import time from bs4 import BeautifulSoup from email.mime.text import MIMEText from email.header import […]
2019-12-11PythonPython+selenium +BeautifulSoup抓取QQ音乐精彩评论(涉及点击加载更多的处理方式)
# 本地Chrome浏览器设置方法 from selenium import webdriver import time #本地一定得在环境根目录下安装谷歌浏览器的驱动 driver = webdriver.Chrome() from bs4 import BeautifulSoup import […]
2019-12-11Python# 以下方法都可以从网页中提取出’你好,蜘蛛侠!’这段文字 find_element_by_tag_name:通过元素的名称选择 # 如<h1>你好,蜘蛛侠!</h1> # 可以使用find_element_by_tag_name(‘h1’) find_element_by_ […]
2019-12-10Pythonimport requests,openpyxl # 创建工作薄 wb=openpyxl.Workbook() # 获取工作薄的活动表 sheet=wb.active # 工作表重命名 sheet.title=’lyrics’ sheet[‘A1′] =’歌曲名’ # 加表头,给A1单元格赋值 sh […]
2019-12-10Pythoncrv文件写入: # 引用csv模块。 import csv # 调用open()函数打开csv文件,传入参数:文件名“demo.csv”、写入模式“w”、newline=”、encoding=’utf-8’。 csv_file = open(‘demo.csv’,’w’,newline=”,e […]
2019-12-10Python
联系站长
友情链接
其他入口
QQ与微信加好友
粤ICP备17018681号 站点地图 www.iamdu.com 版权所有 服务商提供:阿里云 Designed by :DU
本站部分资源内容来源于网络,若侵犯您的权益,请联系删除!