第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
  • https協(xié)議是帶小??標(biāo)記的是安全的
    http沒有
    查看全部
  • ? ? ? ? ? ? ? ? ? ? ? ? ? ?Xpathl路徑表達(dá)式

    • Xpath使用路徑表達(dá)式來選取XML文檔(或是HTML文檔)中的節(jié)點或節(jié)點集?

    ? ? ? ? ? ?路徑表達(dá)式:

    ? ? ? ? ? ? ? ? ? ? ? /div:從根節(jié)點開始選取div節(jié)點

    ? ? ? ? ? ? ? ? ? ? ?//a:選取文檔中所有的a節(jié)點而不考慮其位置

    ? ? ? ? ? ? ? ? ? ? @class:選取名為class的屬性

    ? ? ? ? ? ? ? ? ? ? ?.? :選取當(dāng)前節(jié)點

    ? ? ? ? ? ? ? ? ? ? ?..? :選取當(dāng)前節(jié)點的父節(jié)點


    ctrl+shift+x 打開Xpath


    /div/a :從根節(jié)點開始選取div節(jié)點下的a節(jié)點

    /div/a[@class='header-wrapper' ]

    查看全部
  • 請求頭

    查看全部
    1. etree用來添加HTML和body標(biāo)簽

    data?=?"""
    ??<div>
    ????<ul>
    ?????<li?class="item-0"><a?href="link1">first</a></li>
    ?????<li?class="item-in"><a?href="link2"><span?class="bold">second</span></a></li>
    ?????<li?class="item-0"><a?href="link3">third</a></li>
    ????</ul>
    ??</div>
    """
    html?=?etree.HTML(data)

    ????

    ????2.獲取第一個li的a標(biāo)簽

    1.print(html.xpath("http://li/a[@href='link1']"))
    2.print(html.xpath("http://li[1]/a[1])

    ????3.獲取第二個li的span標(biāo)簽

    1.#因為span是li的后代元素,所以要用兩個//
    2.print(html.xpath("http://li//span"))

    ????4.獲取最后一個li里面的href(last的使用)

    print(html.xpath("http://li[last()]/a/@href"))
    查看全部
    0 采集 收起 來源:lxml模塊

    2022-04-10

    1. 設(shè)置代理——隱藏請求

    查看全部
  • 第二遍沒太聽懂

    查看全部
  • 619f416c0001aa1d10000563.jpg百度的返回頭如何設(shè)置 cookies
    查看全部
  • 百度的返回頭如何設(shè)置 cookies


    619f41350001aa1d10000563.jpg
    查看全部
  • 搜索

    復(fù)制

    查看全部
  • 搜索

    復(fù)制

    查看全部
  • 關(guān)閉校驗:verify=False


    指定證書:verify='xxx'(某個路徑)

    搜索

    復(fù)制

    查看全部
  • session信息

    查看全部
  • Requests模塊構(gòu)造URL

    查看全部
  • PUT方法

    查看全部
  • HTTP POST方法用于提交數(shù)據(jù)(如表單)

    查看全部
  • Head方法請求部分信息

    查看全部
  • HTTP方法GET

    查看全部
  • request是一個Python三方庫

    查看全部
  • import?pymongo
    
    #?指定客戶端連接mongodb
    pymongo_client?=?pymongo.MongoClient("mongodb://localhost:27017")
    #?指定數(shù)據(jù)庫名稱
    pymongo_db?=?pymongo_client["imooc"]
    #?創(chuàng)建集合,創(chuàng)建表
    pymongo_collection?=?pymongo_db["pymongo_test"]
    data?=?{
    ????"name":?"imooc",
    ????"flag":?1,
    ????"url":?"http://idcbgp.cn"
    }
    mylist?=?[
    ????{"name":?"imooc",?"flag":?"123",?"url":?"http://idcbgp.cn"},
    ????{"name":?"taobao",?"flag":?"456",?"url":?"http://idcbgp.cn"},
    ????{"name":?"qq",?"flag":?"761",?"url":?"http://idcbgp.cn"},
    ????{"name":?"知乎",?"flag":?"354",?"url":?"http://idcbgp.cn"},
    ????{"name":?"微博",?"flag":?"954",?"url":?"http://idcbgp.cn"}
    ]
    #?pymongo_collection.insert_one(data)
    #?pymongo_collection.insert_many(mylist)
    #?result=pymongo_collection.find({},{"_id":0,"name":1,"url":1,"flag":1})
    #?result=pymongo_collection.find({},{"_id":0,"name":1,"url":1,"flag":1})
    #?result=pymongo_collection.find_one()
    #?print(result)
    #?for?item?in?result:
    #?????print(item)
    #?大于一百
    #?find_result=pymongo_collection.find({"flag":{"$gt":100}})
    #?首字母t
    #?find_result=pymongo_collection.find({"name":{"$regex":"^t"}})
    #?for?item?in?find_result:
    #?????print(item)
    #?pymongo_collection.update_one({"name":{"$regex":"^t"}},{"$set":{"name":"baidu"}})
    #?pymongo_collection.delete_one({"name":"微博"})
    pymongo_collection.delete_many({})
    查看全部
    0 采集 收起 來源:課程總結(jié)

    2021-07-11

  • import?requests
    from?lxml?import?etree
    from?pymongo.collection?import?Collection
    import?pymongo
    
    print("開始0")
    
    
    class?Dangdang(object):
    ????mongo_client=pymongo.MongoClient(host="localhost",port=27017)
    ????dangdang_db=mongo_client["dangdang_db"]
    ????def?__init__(self):
    ????????self.header?=?{
    ????????????"Host":?"bang.dangdang.com",
    ????????????"Connection":?"keep-alive",
    ????????????"Cache-Control":?"max-age=0",
    ????????????"Upgrade-Insecure-Requests":?"1",
    ????????????"User-Agent":?"Mozilla/5.0?(Windows?NT?10.0;?Win64;?x64)?AppleWebKit/537.36?(KHTML,?like?Gecko)?Chrome/91.0.4472.124?Safari/537.36",
    ????????????"Accept":?"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
    ????????????"Referer":?"http://bang.dangdang.com/books/bestsellers/01.00.00.00.00.00-24hours-0-0-1-2",
    ????????????"Accept-Encoding":?"gzip,deflate",
    ????????????"Accept-Language":?"zh-CN,zh;q=0.9"
    ????????}
    ????????self.dangdang=Collection(Dangdang.dangdang_db,"dangdang")
    
    ????def?get_dangdang(self,?page):
    ????????"""發(fā)送請求到當(dāng)當(dāng)網(wǎng)獲取數(shù)據(jù)"""
    ????????url?=?"http://bang.dangdang.com/books/bestsellers/01.00.00.00.00.00-24hours-0-0-1-%s"?%?page
    ????????response?=?requests.get(url=url,?headers=self.header)
    ????????if?response:
    ????????????#?????????html數(shù)據(jù)實例化
    ????????????#?print(response.text)
    ????????????html1?=?etree.HTML(response.content)
    ????????????items?=?html1.xpath("http://ul[@class='bang_list?clearfix?bang_list_mode']/li")
    ????????????return?items
    
    
    ????def?join_list(self,item):
    ????#?????處理列表→字符串
    ????????return?"".join(item)
    ????def?parse_item(self,items):
    ????????#?????????解析條目
    ????????#?存到mongodb之前的數(shù)據(jù)
    ????????result_list=[]
    ????????for?item?in?items:
    ????????????#?名稱
    ????????????title=item.xpath(".//div[@class='name']/a/@title")
    ????????????#?圖書評論
    ????????????comment=item.xpath(".//div[@class='star']/a/text()")
    ????????????#?作者信息
    ????????????author=item.xpath(".//div[@class='publisher_info'][1]/a[1]/@title")
    ????????????#?價格
    ????????????price=item.xpath(".//div[@class='price']/p[1]/span[1]/text()")
    
    ????????????result_list.append(
    ????????????????{
    ????????????????????"title":self.join_list(title),
    ????????????????????"comment":self.join_list(comment),
    ????????????????????"author":self.join_list(author),
    ????????????????????"price":self.join_list(price)
    ????????????????}
    ????????????)
    ????????return?result_list
    ????def?insert_data(self,result_list):
    ????????self.dangdang.insert_many(result_list)
    
    def?main():
    ????d?=?Dangdang()
    ????print("開始")
    ????import?json
    ????for?page?in?range(1,?26):
    ????????items?=?d.get_dangdang(page=page)
    ????????result=d.parse_item(items=items)
    ????????#?print(json.dumps(result))
    ????????print(result)
    ????????#?d.insert_data(result)
    
    if?__name__?==?'__main__':
    ????main()
    查看全部
    0 采集 收起 來源:課程總結(jié)

    2021-07-11

  • http://img1.sycdn.imooc.com//60e9b1c00001ac9407440148.jpg注意單引號雙引號的問題

    http://img1.sycdn.imooc.com//60e9b29900019c9f04180087.jpg孫子標(biāo)簽用//

    獲取最后一個li標(biāo)簽的a標(biāo)簽的href的值

    查看全部
    0 采集 收起 來源:lxml模塊

    2021-07-10

  • xpath


    //div[@class="result c-container new-pmd"]

    //dd[@class="lemmaWgt-lemmaTitle-title J-lemma-title"]/a[3]/text()

    //div[not(contains(@class,"para"))]

    //div[last()-2]

    查看全部
  • Chrome商店 XPath Helper
    查看全部
  • 遇到網(wǎng)絡(luò)問題: ConnectionError異常

    如果HTTP請求返回了不成功的狀態(tài)碼: HTTPError異常

    若請求超時,則拋出一個Timeout異常

    若請求超過了設(shè)定的最大重定向次數(shù),則會拋出一個 TooManyRedirects異常

    查看全部
  • 關(guān)閉SSL校驗:

    response = requests.get(url="?verify=false)

    print(response.text)

    查看全部
  • cookie


    查看全部
  • #?隨便練習(xí)
    print(1)


    查看全部
    0 采集 收起 來源:什么是爬蟲

    2020-12-02

首頁上一頁12下一頁尾頁

舉報

0/150
提交
取消
¥88.00
立即購買
課程須知
Python語言開發(fā),入門簡單,人人都可以學(xué)會的爬蟲課程。項目案例真實,數(shù)據(jù)量大,整套代碼極簡,擴展性強,通過調(diào)整修改可實現(xiàn)所有網(wǎng)頁抓取。
老師告訴你能學(xué)到什么?
由淺入深入門Python爬蟲開發(fā),熟練掌握requests、xpath、MongoDB,擁有爬蟲開發(fā)實戰(zhàn)經(jīng)驗,解決實際工作中爬取網(wǎng)頁問題。

微信掃碼,參與3人拼團

微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復(fù)購買,感謝您對慕課網(wǎng)的支持!