love confess
Created|Updated
|Post Views:
I once dreamed of a princess like you being mine. Do you love me?
Related Articles
2021-12-23
beautifulSoup practice
本次我采用BeautifulSoup爬取网页数据,并打印到csv文件中,相比于selenium,BeautifulSoup更加快速。 有几个值得注意的问题 编码 find()和find_all() find()返回指定元素 find_all()返回指定元素的列表 table=soup.find("tbody").find_all("tr")这里先用find()找到第一个tbody, 再用find_all()返回tbody中所有的tr元素列表。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879from bs4 import BeautifulSoupimport requestsimport rerankList =...
2022-01-09
世界大学数据爬取+可视化
数据爬取12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import reimport pandas as pdfrom selenium import webdriverfrom bs4 import BeautifulSoupfrom selenium.webdriver.common.by import Bydef create_web_driver(url): # 不打开浏览器的情况下,爬取数据 options=webdriver.ChromeOptions() # 无头模式 #options.add_argument('--headless') # 不加载图片 prefs = { ...
2022-01-06
中国大学数据分析
Selenium效率低的缺点,但有着可见即可爬的优点。BeautifulSoup本来是用于更快地提取html代码中的数据,效率高,但难以爬取动态网页。 所以,我想采取Selenium+BeautifulSoup的方式,高效爬取动态网页。 先selenium经一系列的操作之后,brower.page_source 获取源码 将源码传给BeautifulSoup,快速爬取 下面以中国大学项目作为实例: 12345678910create database collegesdb charset utf8;use collegesdb;create table t(ranking int,name VARCHAR(20),abroad_rate float(10,1),employment_rate float(10,1),numberOfGraduate int,numberOfUndergraduate...
2022-01-19
爬取kw音乐
headers JS逆向 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950import requestssearchkey=input('请输入歌手名字:')headers={ 'Cookie': 'kw_token=HJFZGV04WSS', # 主机域名 'Host': 'www.kuwo.cn', # 认证令牌 'csrf': 'HJFZGV04WSS', # 防盗链 'Referer': 'http://www.kuwo.cn/search/list?key=%E5%91%A8%E6%9D%B0%E4%BC%A6', # 浏览器信息 'User-Agent':...
2022-01-21
爬取图片
页面滚动由于很多的页面都是动态加载的,在用selenium模拟浏览器时,如果不滚动页面下方,那么有的页面数据就无法加载,所以需要让selenium执行js代码,对页面进行滚动 1234567891011121314def scroll(browser): # 执行这段代码,会获取到当前窗口总高度 js = "return action=document.body.scrollHeight" # 初始化现在滚动条所在高度为0 height = 0 # 当前窗口总高度 new_height = browser.execute_script(js) while height < new_height: # 将滚动条调整至页面底部 for k in range(height, new_height, 300): browser.execute_script('window.scrollTo(0, {})'.format(k)) ...
2021-12-09
自动化播放视频
本次我采用Python+selenium写了一个自动播放视频的脚本。 从账号密码登录,切换一个个window,再到切换一层层frame,最终点击播放按钮的过程。 导入包 1234567from selenium import webdriver from selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.support.wait import WebDriverWaitimport time 将webdriver静音 1234options =...
