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

[µo°Ý] ¨S¦³³]©wª«¥óÅܼƩΠWith°Ï¶ôÅܼÆ

[µo°Ý] ¨S¦³³]©wª«¥óÅܼƩΠWith°Ï¶ôÅܼÆ

[ª©¥DºÞ²z¯d¨¥]
  • GBKEE(2017/8/9 17:03): ªþÀɬݬÝ

  1. Public a As Boolean

  2. Sub StartTimer()
  3.     Range("E7") = "¦Û°Ê§ó·s¡G¶}±Ò"
  4.     If a = True Then End
  5.     DoEvents
  6.     Application.OnTime Now + TimeValue("00:00:01"), "StartTimer2", Schedule:=True
  7. End Sub

  8. Sub StartTimer2()
  9.     DoEvents
  10.     Call NewsOne '§AªºSUB
  11.     Call StartTimer
  12. End Sub

  13. Sub StopTimer()
  14.     a = IIf(a = True, False, True)
  15.     Range("E7") = "¦Û°Ê§ó·s¡GÃö³¬"
  16.     On Error Resume Next
  17.     Application.OnTime Now + TimeValue("00:00:05"), "StartTimer2", Schedule:=False
  18. End Sub

  19. Sub NewsOne()
  20.     Dim url As String, lastRow As Long
  21.     Dim XMLHTTP As Object, html As Object, objResultDiv As Object, objH3 As Object, link As Object
  22.     Dim start_time As Date
  23.     Dim end_time As Date

  24.     lastRow = Range("A" & Rows.Count).End(xlUp).Row

  25.     Dim cookie As String
  26.     Dim result_cookie As String

  27.     start_time = Time
  28.     Debug.Print "start_time:" & start_time

  29.     For i = 1 To lastRow

  30.         url = "https://www.google.co.in/search?&q=" & Cells(i, 1) & "&rnd=" & WorksheetFunction.RandBetween(1, 10000)

  31.         Set XMLHTTP = CreateObject("MSXML2.serverXMLHTTP")
  32.         XMLHTTP.Open "GET", url, False
  33.         XMLHTTP.setRequestHeader "Content-Type", "text/xml"
  34.         XMLHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:25.0) Gecko/20100101 Firefox/25.0"
  35.         XMLHTTP.send

  36.             Set html = CreateObject("htmlfile")
  37.         html.body.innerHTML = XMLHTTP.ResponseText
  38.         Set objResultDiv = html.getelementbyid("rso")
  39.         Set objH3 = objResultDiv.getelementsbytagname("H3")(0)
  40.         Set link = objH3.getelementsbytagname("a")(0)


  41.         str_text = Replace(link.innerHTML, "<EM>", "")
  42.         str_text = Replace(str_text, "</EM>", "")

  43.         Cells(i, 7) = str_text
  44.         Cells(i, 8) = link.href
  45.         DoEvents
  46.     Next

  47.     end_time = Time
  48.     Debug.Print "end_time:" & end_time

  49.     Debug.Print "done" & "Time taken : " & DateDiff("n", start_time, end_time)
  50.     'MsgBox "done" & "Time taken : " & DateDiff("n", start_time, end_time)
  51. End Sub
½Æ»s¥N½X
¤¤¶¡³o¬qºô§}https://www.google.co.in/search?&q=§ï¦¨https://www.google.com.tw/search?&q=´N·|¥X²{¨S¦³³]©wª«¥óÅܼƩΠWith°Ï¶ôÅܼÆ
¿ù»~­ì¦]¸¨¦bstr_text = Replace(link.innerHTML, "<EM>", "")
ÁٽЦѮv­Ì½ç±Ð¡AÁÂÁ¡C

¦^´_ 1# av8d


    °²¦p³o­Óºô§} https://www.google.com.tw/search?&q=
¤£¯à¹³³o­Ó https://www.google.co.in/search?&q=
¤@¼Ë¥i¥H§ì¨ìªF¦è"ª«¥ó"¡F´N·|¥X²{ "¨S¦³³]©wª«¥óÅÜ¼Æ .... "

¶È°µ°Ñ¦Ò

TOP

        ÀR«ä¦Û¦b : ¤H­n¦Û·R¡A¤~¯à·R´¶¤Ñ¤Uªº¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD