Web Scraping ด้วย Python
Thomas Laetsch
Data Scientist, NYU
Selector vs Response:
xpath และ css ตามด้วยเมธอด extract และ extract_firstxpath ใช้งานเหมือน Selectorresponse.xpath( '//div/span[@class="bio"]' )
css ใช้งานเหมือน Selectorresponse.css( 'div > span.bio' )
response.xpath('//div').css('span.bio')
response.xpath('//div').css('span.bio').extract()
response.xpath('//div').css('span.bio').extract_first()
response จดจำ URL ไว้ในตัวแปร response urlresponse.url
>>> 'http://www.DataCamp.com/courses/all'
response ให้เรา "follow" ลิงก์ใหม่ได้ด้วยเมธอด follow()# next_url is the string path of the next url we want to scrape
response.follow( next_url )
follow ในภายหลังWeb Scraping ด้วย Python