Yesterday to interview the interviewer gave a question let me crawl a website information thought: It's so simple small case but open Ctrip station crawl
No flight information was found ... Has reopened Ctrip's website A look I wipe the data incredibly is asynchronously loaded this time some play
Open the console to see the information. There was no flight data at the beginning.
See this request address returned information something like flight data
Try using Python to request a look at the data format
Import urllib.request
import json
url = ' http://flights.ctrip.com/domesticsearch/search/ Searchfirstrouteflights? dcity1=sha&acity1=bjs&searchtype=s&ddate1=2017-10-22&isnearairportrecommond=0&logtoken= D5c2cdde121640c587b2737a160555cc&rk=6.87741369292242094159&ck=b4828167808be5de87c5814b02c113a3&r= 0.44130167627926424060312 '
headers = {'
Host ': ' flights.ctrip.com ',
' user-agent ': ' mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) gecko/20100101 firefox/56.0 ","
Referer ":" Http://flights.ctrip.com/booking/SHA-BJS-day-1.html? Ddate1=2017-10-22 ",
" Connection ":" Keep-alive ",
}
res = urllib.request.Request (url,headers=headers)
res = Urllib.request.urlopen (res). Read (). Decode ("gb2312")
Jsondata = json.loads (res)
print (res)
From the above request, we see that the returned data is encoded as gb2312. We saw the information here. It's really flight information .
See the flight information data in the FIS this array we'll loop around to see if the flight information is correct I took to compare the information is correct finally excited to pay the project offer finally or not get the technology too much to ask Daniel with Q code 823688826 Small white to communicate AH