Can scrapy be used to scrape dynamic content from websites that are using AJAX?

前端 未结 8 798
星月不相逢
星月不相逢 2020-11-21 17:48

I have recently been learning Python and am dipping my hand into building a web-scraper. It\'s nothing fancy at all; its only purpose is to get the data off of a betting we

8条回答
  •  猫巷女王i
    2020-11-21 18:27

    Webkit based browsers (like Google Chrome or Safari) has built-in developer tools. In Chrome you can open it Menu->Tools->Developer Tools. The Network tab allows you to see all information about every request and response:

    enter image description here

    In the bottom of the picture you can see that I've filtered request down to XHR - these are requests made by javascript code.

    Tip: log is cleared every time you load a page, at the bottom of the picture, the black dot button will preserve log.

    After analyzing requests and responses you can simulate these requests from your web-crawler and extract valuable data. In many cases it will be easier to get your data than parsing HTML, because that data does not contain presentation logic and is formatted to be accessed by javascript code.

    Firefox has similar extension, it is called firebug. Some will argue that firebug is even more powerful but I like the simplicity of webkit.

提交回复
热议问题