ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] Ãö©óºô­¶¸ê®Æ§ì¨ú°ÝÃD

¦^´_ 23# sujane0701
Python µ´¹ï¬O­È±o¾Ç²ßªº»y¨¥¡A¸û¼öªù¡A®M¥ó¤]¦h¡C
°Ñ¦Ò VBALearner ªº code ¡A§ï¬° VBA ªº code À³¸Ó¤]¬O¯à¹F¨ì§Aªº»Ý¨Dªº¡G
  1. Sub ¬d¸ß()
  2.     Dim oXmlhttp: Set oXmlhttp = CreateObject("msxml2.xmlhttp")
  3.     Dim oHtml: Set oHtml = CreateObject("htmlfile")
  4.     Dim sUrl As String, sPost As String, sID As String
  5.     Dim ar, r, i, j
  6.    
  7.     With Sheets(1)
  8.         ar = .[a1].Resize(.Cells(.Rows.Count, 1).End(xlUp).Row)
  9.     End With
  10.     For r = 2 To UBound(ar)
  11.         sID = ar(r, 1)
  12.         With oXmlhttp
  13.             sUrl = "https://accs.tradevan.com.tw/accsw-bin/APACCS/userLoginAction.do?userid=GUEST&password=GUEST"
  14.             .Open "Get", sUrl, False
  15.             .send
  16.             oHtml.Body.innerhtml = .responsetext
  17.             sUrl = "https://accs.tradevan.com.tw/accsw-bin/APACCS/cImMergeQueryAction.do"
  18.             sPost = "mawb_no=" & sID & "&¬d¸ß=¬d¸ß"
  19.             sPost = oHtml.parentWindow.encodeURI(sPost)
  20.             .Open "Post", sUrl, False
  21.             .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  22.             .setRequestHeader "Content-Length", Len(sPost)
  23.             .send (sPost)
  24.             oHtml.Body.innerhtml = .responsetext
  25.             With oHtml.GetElementsByTagName("table")(4).Rows(1)
  26.                 sInfo = .Cells(.Cells.Length - 1).GetElementsByTagName("a")(0).href
  27.             End With
  28.             
  29.             sUrl = "https://accs.tradevan.com.tw/accsw-bin/APACCS/cImMergeListAction.do"
  30.             sPost = "mawb_no=" & sID & _
  31.                         "&voyage_flight_no=" & Split(Split(sInfo, "flight_no=")(1), "&")(0) & _
  32.                         "&flight_date=" & Split(Split(sInfo, "flight_date=")(1), "&")(0) & _
  33.                         "&est_arrival_date=" & Split(Split(sInfo, "est_arrival_date=")(1), "&")(0) & _
  34.                         "&qry_mawb_no=" & sID & _
  35.                         "&qry_sort=0"
  36.             sPost = oHtml.parentWindow.encodeURI(sPost)
  37.             .Open "Post", sUrl, False
  38.             .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
  39.             .setRequestHeader "Content-Length", Len(sPost)
  40.             .send (sPost)
  41.             oHtml.Body.innerhtml = .responsetext
  42.             With oHtml.GetElementsByTagName("table")(4)
  43.                 For i = 0 To .Rows.Length - 1
  44.                     With .Rows(i)
  45.                         For j = 0 To .Cells.Length - 1
  46.                             Sheets(2).Cells((r - 2) * 12 + i + 1, j + 1).Value = .Cells(j).innertext
  47.                         Next
  48.                     End With
  49.                 Next
  50.             End With
  51.         End With
  52.     Next
  53. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 26# VBALearner
ºô¸ô¦Û¾Çªº¡A¹ï©¤½×¾Â¦³¤£¿ùªº¸ê®Æ
http://club.excelhome.net/thread-1303169-1-1.html
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

        ÀR«ä¦Û¦b : ¦³¦h¤Ö¤O¶q´N°µ¦h¤Ö¨Æ¡A¤£­n¤ß¦sµ¥«Ý¡Aµ¥«Ý¤~·|¸¨ªÅ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD