Week1_Retrieve Information from Web

In this project, I am trying to retrieve all the item information on one page from 58.com. The logic is, first retrieve all the links on the page, and then depending whether it is the personal item or the commercial item, try to retrieve all the item information on that page based on the unique css selector. 

In the following code, I created two main functions: "get_links(sale_category)" to retrieve all the links and "get_item_info(sale_category)" to retrieve all the detailed item information for each of those links. The "sale_category" determines whether the item belongs to the personal one (0) or commercial one (1). Inside the "get_item_info(sale_category)" function, I am using the "if-else" to separate the personal items and commercial items. The css used to retrieve the detailed item information between the personal and commercial items are also quite different, as you can see in the following code. However, fer the commercial item, I created a function called the "number of views" to get the view number since the details were embedded in the js code. This is something totally new to me, so it is worth mentioning here. 

code_part 1
code_part 2
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容