Giter Site home page Giter Site logo

crawler-shopee2017's Introduction

Crawler-Shopee2017

       抓取方法: 原本找到XHR的連結,連同json的參數透過POST做傳輸,才可送出正確的請求出去。    但如果今天發出請求後,無論如何都得不到回應時,應該是少了某些(Headers),此時要一個一個    的把HEADERS都加入來嘗試,直到找到正確的組合並取得商品資訊。    某些HEADER無法直接用網頁的明細內找到,所以需要搭配Selenium 取得正確Cookie即可!

動作:

  1. 首先我想要搜尋的是二手電腦,因為"金"費不夠買新的XD
  2. 搜尋後點選F12並選擇XHR-->PREVIEW-->ITEM 確定相關的資料確實存在這裡

image

  1. 再點選Headers看到一個POST的連結,複製連結貼上PYTHON image

  2. 但又發現資料卻是JASON的型態,所以點選VIEW SOURCE把資料複製在PYTHON貼上

  3. jd = jason.loads()

  4. res = request.post(link_,json = jd)

  5. RUN之後發現報錯403

  6. 403表示要讀出這些資料還需要HEADER,所以要去找出一個個的HEADERS

  7. 找出來後

  8. headers ={agent,cookie,token,referer} image

  9. 確定可以取得資訊

  10. 輸入res.json()可以得到資料,代表沒問題

  11. 利用Selenium來抓取cookie and token 成為參數 ck & tok

  12. 再把參數加入headers

  13. 此時資料應該就可以抓取到了

  14. 可以利用Pandas把資料分配的比較方便查看

crawler-shopee2017's People

Contributors

egroeglee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.