- ©«¤l
- 102
- ¥DÃD
- 14
- ºëµØ
- 0
- ¿n¤À
- 142
- ÂI¦W
- 0
- §@·~¨t²Î
- Win10
- ³nÅ骩¥»
- Office2016
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2016-7-31
- ³Ì«áµn¿ý
- 2020-3-21
|
¥»©«³Ì«á¥Ñ VBALearner ©ó 2017-2-10 21:24 ½s¿è
¦^´_ 18# sujane0701
¦^´_ 20# c_c_lai
À³C¤jªº´Á«Ý¡A¥[¤J²Ä¤G¦¸POST¡A§¹½Z¡C
·Q·íªìC¤j¤]¦^À³§Ú³\¦hVBAªº§C¯à°ÝÃDxD¡A°O±o·í®É§ÚPO¤F¤@½g¤À¨É¤å"¤T¤jªk¤H¶R½æ¶W¸ê®Æ¾ã²z..."¡Aµ²ªG´N¦³°ª¤â¥ÎPython§â¦Û°Ê¤U¸üExcelªºµ{¦¡½X¶K¥X¨Ó¡A¤Þµo´X¤Q¶ªº¼ö¯P°Q½×¡CY¤£¬O°ª¤âµL¨p¤À¨É¡B¥O§Ú¹ïPython»y¨¥¤j¶}²´¬É¨Ã²£¥Í°ª«×¿³½ìªº¸Ü¡A§Ú«K¤£·|¥h¾Ç²ßPy¡A¥i¯àÁÙ°±¯d¦bVBA§a... ¦]¦¹¡A§¹¾ãªºµ{¦¡½XS¤j¡BC¤j½Ð¨É¥Î¡A¨Ã¹ªÀyPy°ª¤â¹ï§Úªºµ{¦¡½X´£¥X«Ø¨¥¡AS¤j±z±µ¤U¨Ó¥u»Ýn§â¸ê®Æ¦s¦¨Excel¡A³o¤@¨B«Ü²³æ¡Aºô¸ô§ä§ä§a¡A¥[ªo¡C- import requests
- import time
- from bs4 import BeautifulSoup
- postfreq = 0.8 #ÁקK¹L«×ÀWÁcªº³X°Ý³Q·í¦¨´c·Nµ{¦¡§ðÀ»(Ãþ¦ü¤p«¬DDOS)¡A¬í¼Æ¶¡¹j³X°Ý¬Oª¦ÂΪº°ò¥»Â§»ª
- #¶È¥H¨âµ§¥D´£³æ¸¹½X¥Ü½d¡A±ý¼W¥[¦Û¦æ§ó§ï§Y¥i
- ¥D´£³æ¸¹½X = ['160-69306532','608-10318674'] #,'851-26325773','479-32003532','695-08802916','297-64647785']
- with requests.session() as r:
- res = r.get('https://accs.tradevan.com.tw/accsw-bin/APACCS/userLoginAction.do?userid=GUEST&password=GUEST')
- for code in ¥D´£³æ¸¹½X:
- print('¥D´£³æ¸¹½X :',code,'\n')
- time.sleep(postfreq)
- payload = {'mawb_no':code,'¬d¸ß':'¬d¸ß'}
- res = r.post("https://accs.tradevan.com.tw/accsw-bin/APACCS/cImMergeQueryAction.do", data=payload) #²Ä¤@¦¸³X°Ý
- res.encoding = "big-5"
- html = BeautifulSoup(res.text,"html.parser")
- num = 1
- for tr in html.body.select('table')[4].select('tr')[1:]: #§âTable¸Ìªºtr¸ê®Æ³v¦C¨ú¥X
- summary = [] #«Ø¥ßºKn¸ê°Tªº¦s©ñ°}¦C
- postdata = [] #¤G¦¸³X°Ý©Ò»Ý°Ñ¼Æªº¦s©ñ°}¦C
- for td in tr.select('td'):
- summary.append(td.text.strip())
- if td == tr.select('td')[len(tr.select('td'))-1]: #³o¸Ì¦³¤U¤@ÓPOST©Ò»Ýªº¸ê°T(°Ñ¼Æ)¡A³z¹LÆ[¹îºô¶ì©l½X±oª¾
- postdata.append(str(td).split('&')[1].replace('flight_no=','')) #°Ñ¼Æ1
- postdata.append(str(td).split('&')[2].replace('flight_date=','')) #°Ñ¼Æ2
- postdata.append(str(td).split('&')[3].replace('est_arrival_date=','')) #°Ñ¼Æ3
-
- print(' ','ºKn¸ê°T'+str(num),':',summary,'\n') #²Ä¤@¦¸¬d¸ß±o¨ìªººKn¸ê®Æ
- num+=1
- payload = {'mawb_no':code,
- 'voyage_flight_no':postdata[0],
- 'est_arrival_date':postdata[2],
- 'flight_date':postdata[1],
- 'qry_mawb_no':code,
- 'qry_sort':'0'
- }
- time.sleep(postfreq)
- res = r.post("https://accs.tradevan.com.tw/accsw-bin/APACCS/cImMergeListAction.do", data=payload) #²Ä¤G¦¸POST
- res.encoding = "big-5"
- html = BeautifulSoup(res.text,"html.parser")
- print(' ','¸Ô²Ó¸ê®Æ¦p¤U :')
- for tr in html.select('table')[4].select('tr'):
- data = []
- for td in tr.select('td'):
- data.append(td.text.replace('\r','').replace('\n','').replace(' ','').strip())
- print('\t',data)
- print('\n')
- #¹B¥Î¨ä¥L¼Ò²Õ§âª¦¨ìªº¸ê®Æ¦s¦¨Excel§Y¤j¥\§i¦¨¡A¬Æ¦Ü¥i¥H¶i¤@¨B¹B¥Îselect»yªk¿z¿ï¯S©w¦ì¸mªº¸ê®Æ
½Æ»s¥N½X
|
|