Grab Market App Data

Source: Internet
Author: User

#!/usr/bin/env python#-*-coding:utf-8-*-import jsonimport requestsurl = "https://app.ganji.com/datashare/" headers = {            "Content-type": "application/x-www-form-urlencoded", "userid": "c1ed10776d9b6108d8fefee4ea53058a", "Model": "Generic/iphone", "CustomerID": "705", "clientagent": "iphone 6S plus#414*736#11.0.3            "," VersionID ":" 8.3.0 "," OS ":" ios "," net ":" WiFi "," DV ":" IPhone 6S Plus ", "Interface": "SearchPostsByJson3", "Accept-language": "ZH-CN",}def req (URL, headers, data): Cont ent = None try:r = requests.post (URL, headers=headers, Data=data, timeout=5) content = R.json () excep    T Exception as E:print ("Requests error:", E, "Requests URL:", url) return contentdef get_ganji_list_data (): # get list data = ' t=-576747455&&showtype=0&showtype=0&jsonargs={"pageSize": "Cityscriptindex" : 2300, "Majorcategoryscriptindex": 7, "queryfilters": [], "categoryId": 7, "andkeywords": [{"Name": "title", "Value": "%e5%95%86%e9%93%ba%e5%87%ba%e5%94% AE "}]," CustomerId ":" 705 "," sortkeywords ": [{" Field ":" Post_at "," Sort ":" desc "}]," PageIndex ": 1} ' Ganji_data = req (URL, headers, data) If Ganji_data is not None:return ganji_data return nonedef get_article_data (): Ganji_data = Get_ganji_list_data () If ganji_data is not none:data_list = ganji_data["Posts"] Print ("Count:", Ganji _data["Total"]) for Data_ in Data_list:title, d_sign, Puid = data_["title"], data_["D_sign"], data_["Pu ID "] Print (title, d_sign) data_article =" d_sign={0}&cityid=176&post_type_for_maidian=5& Categoryid=7&spfy=0 ". Format (d_sign) # Gets the details based on PUID. Puid need to be placed in headers headers["interface"] = "Getpostbypuid" headers["puid"] = Puid content_d              ata = req (URL, headers, data_article) if content_data["status"] = = 0:  data = content_data["Data"] End_data = {} end_data["price"] = data["Price" ["V"] end_data["Price_unit"] = data["Price" ["U"] end_data["title"] = data["title"] End_data ["City"] = data["City"] end_data["description"] = data["description"] end_data["District_nam  E "] = data[" District_name "] end_data[" street_name "] = data[" Street_name "] end_data[" LATLNG "] = data["latlng"] end_data["id"] = data["id"] Time.sleep (2)

The header is really a lot of things, the final test only need these kinds of, exhausted baby,

Grab Market App Data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.