import requests
import pandas as pd
import arrow
import json
import os
from itertools import combinations
os.chdir(r'C:/Users/Windows/Desktop')
class HighSpeed(object):
def __init__(self,date,from_station,to_station):
self.date = date
self.from_station = from_station
self.to_station = to_station
def get_pd(self):
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)Chrome/80.0.3970.5 Safari/537.36'}
r = requests.get('https://www.12306.cn/kfzmpt/lcxxcx/query?purpose_codes=ADULT&queryDate='+self.date+'&from_station='+self.to_station+'&to_station='+self.from_station, headers = headers).text
return r
def to_csv(self):
js = self.get_pd()
j