您好,登錄后才能下訂單哦!
這篇文章主要介紹cookie怎么在python爬蟲中獲取主頁信息,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
我們在代碼中直接獲取我的個人信息
import requests headers = { # 假裝自己是瀏覽器 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/73.0.3683.75 Chrome/73.0.3683.75 Safari/537.36', # 把你剛剛拿到的Cookie塞進來 'Cookie': 'eda38d470a662ef3606390ac3b84b86f9; Hm_lvt_f1d3b035c559e31c390733e79e080736=1553503899; biihu__user_login=omvZVatKKSlcXbJGmXXew9BmqediJ4lzNoYGzLQjTR%2Fjw1wOz3o4lIacanmcNncX1PsRne5tXpE9r1sqrkdhAYQrugGVfaBICYp8BAQ7yBKnMpAwicq7pZgQ2pg38ZzFyEZVUvOvFHYj3cChZFEWqQ%3D%3D; Hm_lpvt_f1d3b035c559e31c390733e79e080736=1553505597', } session = requests.Session() response = session.get('https://biihu.cc/people/wistbean%E7%9C%9F%E7%89%B9%E4%B9%88%E5%B8%85', headers=headers) print(response.text)
運行后可以發現不用登錄就可以直接拿到自己的個人信息了
<!DOCTYPE html> <html> <head> <meta content="text/html;charset=utf-8" http-equiv="Content-Type" /> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1" /> <meta name="renderer" content="webkit" /> <title>小帥b真特么帥 的個人主頁 - 逼乎</title> <meta name="keywords" content="逼乎,問答,裝逼,逼乎網站" /> <meta name="description" content="逼乎 ,與世界分享你的裝逼技巧與見解" /> <base href="https://biihu.cc/" /><!--[if IE]></base><![endif]--> <link rel="stylesheet" type="text/css" href="https://biihu.cc/static/css/bootstrap.css" /> <link rel="stylesheet" type="text/css" href="https://biihu.cc/static/css/icon.css" /> <link href="https://biihu.cc/static/css/default/common.css?v=20180831" rel="stylesheet" type="text/css" /> <link href="https://biihu.cc/static/css/default/link.css?v=20180831" rel="stylesheet" type="text/css" /> <link href="https://biihu.cc/static/js/plug_module/style.css?v=20180831" rel="stylesheet" type="text/css" /> <link href="https://biihu.cc/static/css/default/user.css?v=20180831" rel="stylesheet" type="text/css" /> <link href="https://biihu.cc/static/css/mood/mood.css" rel="stylesheet" type="text/css" /> <script type="text/javascript"> var _02AEC94D5CA08B39FC0E1F7CC220F9B4="a5359326797de302bfc9aa6302c001b8"; var G_POST_HASH=_02AEC94D5CA08B39FC0E1F7CC220F9B4; var G_INDEX_SCRIPT = ""; var G_SITE_NAME = "逼乎"; var G_BASE_URL = "https://biihu.cc"; var G_STATIC_URL = "https://biihu.cc/static"; var G_UPLOAD_URL = "/uploads"; var G_USER_ID = "188"; var G_USER_NAME = "小帥b真特么帥"; var G_UPLOAD_ENABLE = "Y"; var G_UNREAD_NOTIFICATION = 0; var G_NOTIFICATION_INTERVAL = 100000; var G_CAN_CREATE_TOPIC = "1"; var G_ADVANCED_EDITOR_ENABLE = "Y"; var FILE_TYPES = "jpg,jpeg,png,gif,zip,doc,docx,rar,pdf,psd"; </script> <script src="https://biihu.cc/static/js/jquery.2.js?v=20180831" type="text/javascript"></script> ....
以上是“cookie怎么在python爬蟲中獲取主頁信息”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。