-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
# 通过登陆 进入到主页面 | ||
|
||
|
||
# 通过找登陆接口发现登陆时候需要的参数很多在login中找 | ||
|
||
# __VIEWSTATE: kBeYlQh4JeI1J7uQdLrUffn6FHUW2mJE8dKQYKQypdnw4kIi6ZE63qg6WoLKkbeVKkpzY+XGF3E2dB/e4nViUEKrd7gvgC4uyMiNOUcKptmPrYXxO0hgkpyZhIQ= | ||
# __VIEWSTATEGENERATOR: C93BE1AE | ||
# from: http://so.gushiwen.cn/user/collect.aspx | ||
# email: [email protected] | ||
# pwd: 1233312 | ||
# code: z0x6 | ||
# denglu: 登录 | ||
|
||
# 观察到__VIEWSTATE, __VIEWSTATEGENERATOR,以及code是变化的 | ||
|
||
|
||
# 难点:(1)__VIEWSTATE, __VIEWSTATEGENERATOR 一般情况下看不到的数据都在页面的源码中 | ||
# 观察到两个数据在页面的源码中,因此我们需要获取页面的源码然后进行解析就可以了 | ||
# (2)验证码 | ||
import urllib.request | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
# 登陆页面的Url地址 | ||
url = 'https://so.gushiwen.cn/user/login.aspx?from=http://so.gushiwen.cn/user/collect.aspx' | ||
|
||
headers = { | ||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36' | ||
} | ||
|
||
# 获取页面的源码 | ||
response = requests.get(url=url, headers=headers) | ||
content = response.text | ||
|
||
# print(content) | ||
|
||
# 解析页面源码获取__VIEWSTATE, __VIEWSTATEGENERATOR的值 | ||
|
||
|
||
soup = BeautifulSoup(content, 'lxml') | ||
|
||
# 获取__VIEWSTATE | ||
viewstate = soup.select('#__VIEWSTATE')[0].attrs.get('value') | ||
|
||
# 获取__VIEWSTATEGENERATOR的值 | ||
viewstategenerator = soup.select('#__VIEWSTATEGENERATOR')[0].attrs.get('value') | ||
|
||
|
||
# 获取验证码图片 | ||
|
||
code = soup.select('#imgCode')[0].attrs.get('src') | ||
# print(code) | ||
|
||
code_url = 'https://so.gushiwen.cn'+code | ||
# print(code_url) | ||
|
||
# 有坑 | ||
# urllib.request.urlretrieve(url=code_url, filename='code.jpg') | ||
|
||
# requests里面有一个方法交session(),通过session的返回值就能使得请求变成对象 | ||
session = requests.session() | ||
# 验证码的url的内容 | ||
response_code = session.get(code_url) | ||
# 注意此时要使用二进制数据,因为我们要使用图片的瞎子啊 | ||
content_code = response_code.content | ||
# wb模式是将二进制数据写入文件 | ||
with open('code.jpg', 'wb')as fp: | ||
fp.write(content_code) | ||
|
||
# 获取验证码的图片之后下载到本地观察验证码在控制台输入验证码可以将值赋给code参数 | ||
code_name = input('请输入你的验证码:') | ||
|
||
# 点击登录 | ||
|
||
url_post = 'https://so.gushiwen.cn/user/login.aspx?from=http%3a%2f%2fso.gushiwen.cn%2fuser%2fcollect.aspx' | ||
|
||
data_post = { | ||
'__VIEWSTATE': viewstate, | ||
'__VIEWSTATEGENERATOR': viewstategenerator, | ||
'from': 'http://so.gushiwen.cn/user/collect.aspx', | ||
'email': '[email protected]', | ||
'pwd': '2bldhbfh', | ||
'code': code_name, | ||
'denglu': '登录', | ||
} | ||
|
||
response_post = session.post(url=url, headers=headers, data=data_post) | ||
|
||
content_post = response_post.text | ||
|
||
with open('gushiwen.html', 'w', encoding='utf-8')as fp: | ||
fp.write(content_post) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" id="html"> | ||
<head><meta http-equiv="Cache-Control" content="no-siteapp" /><meta http-equiv="Cache-Control" content="no-transform " /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title> | ||
我的收藏_古诗文网 | ||
</title> | ||
<script src="/js/jquery-3.2.1.min.js" type="text/javascript"></script> | ||
<style type="text/css">.mainshoucang{width:705px;height:34px;line-height:34px;border-bottom:1px solid #d7d5bc;overflow:hidden;float:left;clear:left;}.mainshoucang span{float:right;margin-top:15px;margin-left:5px;color:#65645F;}.mainshoucang a{float:right;margin-top:15px;margin-left:5px;}</style> | ||
<script type="text/javascript">if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {window.location.href ="https://m.gushiwen.cn/user/collect.aspx?type=s&p=1&id=2124231&sort=t";} else {} | ||
</script> | ||
<link href="/css/skinSo20210826.css" rel="stylesheet" type="text/css" /> | ||
<script src="/js/jquery-3.2.1.min.js" type="text/javascript"></script> | ||
<script type="text/javascript">function getCookie(name) {var arr,reg =new RegExp("(^| )" + name + "=([^;]*)(;|$)");if (arr =document.cookie.match(reg)) | ||
return unescape(arr[2]);else | ||
return null;} | ||
function selectLike(id) {document.getElementById('likeImg' + id).name =parseInt(document.getElementById('likeImg' + id).name) + 1;if (document.getElementById('likeImg' + id).name =='1') {var idsShigeLaiyo =getCookie('idsShiwen2017');if (idsShigeLaiyo !=null &&idsShigeLaiyo !='') {var ids =idsShigeLaiyo.split(',');for (var i =0;i < ids.length;i++) {if (ids[i] ==id) {document.getElementById('likeImg' + id).src ='https://song.gushiwen.cn/siteimg/shou-cangok.png';document.getElementById('likeImg' + id).alt ='已收藏';break;} | ||
} | ||
} | ||
} | ||
} | ||
function selectLikeMingju(id) {document.getElementById('likeImg' + id).name =parseInt(document.getElementById('likeImg' + id).name) + 1;if (document.getElementById('likeImg' + id).name =='1') {var idsShigeLaiyo =getCookie('idsMingju2017');if (idsShigeLaiyo !=null &&idsShigeLaiyo !='') {var ids =idsShigeLaiyo.split(',');for (var i =0;i < ids.length;i++) {if (ids[i] ==id) {document.getElementById('likeImg' + id).src ='https://song.gushiwen.cn/siteimg/shou-cangok.png';document.getElementById('likeImg' + id).alt ='已收藏';break;} | ||
} | ||
} | ||
} | ||
} | ||
function selectLikeAuthor(id) {document.getElementById('likeImg' + id).name =parseInt(document.getElementById('likeImg' + id).name) + 1;if (document.getElementById('likeImg' + id).name =='1') {var idsShigeLaiyo =getCookie('idsAuthor2017');if (idsShigeLaiyo !=null &&idsShigeLaiyo !='') {var ids =idsShigeLaiyo.split(',');for (var i =0;i < ids.length;i++) {if (ids[i] ==id) {document.getElementById('likeImg' + id).src ='https://song.gushiwen.cn/siteimg/shou-cangok.png';document.getElementById('likeImg' + id).alt ='已收藏';break;} | ||
} | ||
} | ||
} | ||
} | ||
function selectLikeGuwen(id) {document.getElementById('likeImg' + id).name =parseInt(document.getElementById('likeImg' + id).name) + 1;if (document.getElementById('likeImg' + id).name =='1') {var idsShigeLaiyo =getCookie('idsGuji2017');if (idsShigeLaiyo !=null &&idsShigeLaiyo !='') {var ids =idsShigeLaiyo.split(',');for (var i =0;i < ids.length;i++) {if (ids[i] ==id) {document.getElementById('likeImg' + id).src ='https://song.gushiwen.cn/siteimg/shou-cangok.png';document.getElementById('likeImg' + id).alt ='已收藏';break;} | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
<script>var _hmt =_hmt ||[];(function () {var hm =document.createElement("script");hm.src ="//hm.baidu.com/hm.js?9007fab6814e892d3020a64454da5a55";var s =document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm,s);})();</script> | ||
</head> | ||
<body onclick="closeshowBos()"> | ||
<div class="main1"> | ||
<div class="cont"> | ||
<div class="left"> | ||
<a href="https://www.gushiwen.cn/">古诗文网</a> | ||
</div> | ||
<div class="right"> | ||
<div class="son1"> | ||
<a style="margin-left:1px;" href="https://www.gushiwen.cn/">推荐</a> | ||
<a href="/shiwens/">诗文</a> | ||
<a href="/mingjus/">名句</a> | ||
<a href="/authors/">作者</a> | ||
<a href="/guwen/">古籍</a> | ||
<a href="/user/collect.aspx" rel="nofollow" style="background-color:#757863;border-bottom:3px solid #F0EFE2;line-height:43px; height:43px;">我的</a> | ||
<a style="width:65px;" href="/app/DefaultGwd.aspx" target="_blank">手机版</a> | ||
</div> | ||
<div class="son2"> | ||
<div class="search"> | ||
<form action="/search.aspx" onsubmit="return selectSearch()" contentType="text/html; charset=utf-8"> | ||
<input onkeydown="noajaxkeyUp()" onfocus="setInterval('showBos()',1000)" id="txtKey" name="value" type="text" value="" maxlength="40" autocomplete="off" style="height:25px; line-height:25px; float:left; padding-left:5px; width:260px; font-size:14px; clear:left; border:0px;" /> | ||
<input type="submit" style="float:right; width:24px; height:24px; clear:right; margin-top:2px; margin-right:3px; background-image:url(https://song.gushiwen.cn/siteimg/docSearch.png); background-repeat:no-repeat; background-size:24px 24px; border:0px;cursor:pointer;" value="" /> | ||
<input id="b" style="display:none;" type="text" /> | ||
</form> | ||
</div> | ||
<div id="box"></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div style="width:1000px; clear:both; margin-left:auto; margin-right:auto; margin-top:20px; overflow:hidden;"> | ||
<div class="mainshoucang"> | ||
<span style=" height:34px; line-height:34px;font-size:18px; font-weight:bold; float:left; margin:0px; color:#0F0F0F;">我的收藏</span> | ||
<span style=" height:34px; line-height:34px;font-size:18px; font-weight:bold; float:left; margin:0px; color:#0F0F0F; margin-left:10px; margin-right:10px;">/</span> | ||
<a style=" height:34px; line-height:34px;font-size:18px; font-weight:bold; float:left; margin:0px;" href="/user/collectbei.aspx?sort=t">我的背诵</a> | ||
<a href="/user/collect.aspx?type=s&id=2124231&sort=z">字母排序</a> | ||
<span>/</span> | ||
<span>时间排序</span> | ||
</div> | ||
<div style="width:265px;height:34px; line-height:34px; border-bottom:1px solid #C5C5C5;overflow:hidden; clear:right; float:right;font-size:14px;"> | ||
账号管理 | ||
</div> | ||
</div> | ||
<div id="mainSearch" class="mainSearch"> | ||
<div class="searchleft"> | ||
<a style="color:#FFFFFF;background-image:url(https://song.gushiwen.cn/siteimg/seachimg.jpg); background-repeat:no-repeat;">诗文</a> | ||
<a href="/user/collect.aspx?type=m&id=2124231&sort=t">名句</a> | ||
<a href="/user/collect.aspx?type=a&id=2124231&sort=t">作者</a> | ||
<a href="/user/collect.aspx?type=d&id=2124231&sort=t">古籍</a> | ||
</div> | ||
<div class="left"> | ||
<img src="shoucangdemo.jpg" style=" margin-top:20px;" alt="收藏教程" width="620" height="556" /> | ||
<form id="FromPage" method="get" action="/user/collect.aspx" onsubmit="return PageSubmit()"> | ||
<div class="pagesright"> | ||
<a class="amore" style=" color:#808080;background-color:#e7e6d8;width:380px;">下一页</a> | ||
<a style=" color:#808080;background-color:#e7e6d8;">上一页</a> | ||
<span style=" background-color:#E1E0C7; border:0px; margin-top:22px; width:auto;">/ 1页</span> | ||
<span class="curent"><input id="putpage" name="p" value="1" autocomplete="off" onblur="SubPage()" /></span> | ||
<label id="temppage" style="display:none;">1</label> | ||
<label id="sumPage" style="display:none;">1</label> | ||
<input type="hidden" name="sort" value="t" /> | ||
<input type="hidden" name="id" value="2124231" /> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="right"> | ||
<div class="shisoncont"> | ||
<div class="line"><a href="/user/modifypwd.aspx?from=http://so.gushiwen.cn/user/collect.aspx">修改密码</a></div> | ||
<div class="line"><a href="/user/bandemail.aspx?from=http://so.gushiwen.cn/user/collect.aspx">绑定邮箱</a><span>*****[email protected]</span></div> | ||
<div class="line"><a href="/user/bandphone.aspx?from=http://so.gushiwen.cn/user/collect.aspx">绑定手机号</a><span>未绑定</span></div> | ||
<div class="line"><a id="bwxhao" style="cursor:pointer;">绑定公众号</a><span id="bwxbool"></span></div> | ||
<div class="line"><a href="/user/loginlose.aspx?from=http://so.gushiwen.cn/user/collect.aspx">退出登录</a></div> | ||
<div class="line" style=" border-bottom:0px;"><a href="/user/userDel.aspx">删除账号</a></div> | ||
</div> | ||
<div id="threeWeixin" style="display:none;"> | ||
<div class="hide-center" id="hide-center"> | ||
<div id="formhead"> | ||
<div id="formhead-title"> | ||
绑定公众号(可扫码登录) | ||
</div> | ||
<button type="button" id="close" style="color:#bcba9e;">X</button> | ||
</div> | ||
<div id="formbody"> | ||
<img id="erweimaCanshu" width="210" height="210" src="" alt="" /> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript">function getCookie(name) {var arr,reg =new RegExp("(^| )" + name + "=([^;]*)(;|$)");if (arr =document.cookie.match(reg)) | ||
return unescape(arr[2]);else | ||
return null;} | ||
$("#close").click(function () {$("#threeWeixin").fadeOut("slow");clearInterval(intervalErweima);}) | ||
var timesRun =0;var scene_id =Math.floor((Math.random() *9999999) + 100000000);var wxopenid =getCookie('wxopenid');if (wxopenid =null) {document.getElementById('bwxbool').innerHTML ='未绑定' | ||
} | ||
else {document.getElementById('bwxbool').innerHTML ='已绑定' | ||
} | ||
var threeWeixinID =document.getElementById('threeWeixin');var erweimaShow =0;$("#bwxhao").click(function () {if (threeWeixinID.style.display !='none') {document.getElementById('hide-center').style.top =$(window).scrollTop() *2 + "px";return;} | ||
setTimeout(showErweima,1000);}) | ||
function showErweima() {var xmlhttp;if (window.XMLHttpRequest) {xmlhttp =new XMLHttpRequest();} | ||
else {xmlhttp =new ActiveXObject("Microsoft.XMLHTTP");} | ||
xmlhttp.onreadystatechange =function () {if (xmlhttp.readyState ==4 &&xmlhttp.status ==200) {document.getElementById('erweimaCanshu').src ="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + xmlhttp.responseText;} | ||
} | ||
xmlhttp.open("GET","/getTicket.aspx?scene_id=" + scene_id,false);xmlhttp.send();document.getElementById('hide-center').style.top =$(window).scrollTop() *2 + "px";$("#threeWeixin").fadeIn("slow");timesRun =0;var intervalErweima =setInterval("selectErweima()","2000");} | ||
function selectErweima() {timesRun =timesRun + 1;if (timesRun >60) {$("#threeWeixin").fadeOut("slow");clearInterval(intervalErweima);} | ||
var xmlhttp;if (window.XMLHttpRequest) {xmlhttp =new XMLHttpRequest();} | ||
else {xmlhttp =new ActiveXObject("Microsoft.XMLHTTP");} | ||
xmlhttp.onreadystatechange =function () {if (xmlhttp.readyState ==4 &&xmlhttp.status ==200) {if (xmlhttp.responseText !="未扫码") {$("#threeWeixin").fadeOut("slow");erweimaShow =1;clearInterval(intervalErweima);} | ||
} | ||
} | ||
xmlhttp.open("POST","/getEventKey.aspx?&scene_id=" + scene_id,false);xmlhttp.send();} | ||
</script> | ||
<div class="juzioncont"> | ||
<img style=" float:left; margin:10px; margin-right:0px;" src="https://song.gushiwen.cn/siteimg/app/appdownGwd2021.png" width="80" height="80" /><p><center style="font-size:18px; margin-top:14px;">扫码下载</center></p><p><center style="font-size:18px; margin-top:5px;">古文岛客户端</center></p> | ||
</div> | ||
<div class="juzioncont"> | ||
<img style=" float:left; margin:10px; margin-right:0px;" src="https://song.gushiwen.cn/siteimg/app/erma_guwendao.png" width="80" height="80" /><p><center style="font-size:18px; margin-top:14px;">扫码关注</center></p><p><center style="font-size:18px;margin-top:5px;">古文岛公众号</center></p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="main4"> | ||
© 2021 <a href="https://www.gushiwen.cn/">古诗文网</a> | <a href="https://so.gushiwen.cn/shiwens/">诗文</a> | <a href="https://so.gushiwen.cn/mingjus/">名句</a> | <a href="https://so.gushiwen.cn/authors/">作者</a> | <a href="https://so.gushiwen.cn/guwen/">古籍</a> | <a href="/jiucuo.aspx?u=" target="_blank" rel="nofollow">纠错</a> | ||
</div> | ||
<script type="text/javascript">window.onload =function () {setIframeHeight(document.getElementById('external-frame'));};</script> | ||
<script defer="defer" src="/js/skinso20210902.js" type="text/javascript"></script> | ||
</body> | ||
</html> |