- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 1# msmplay
µ{¦¡½X½Æ»s¦b¦P¤@¼Ò²Õ¤W- Option Explicit
- Dim ¹Ï¤ù¥Ø¿ý As String, ¹Ï¤ù¼Æ As Double, ¹Ï¤ù¦WºÙ As String
- Sub Ex_§ì¨ú¦hºô¶¸ê®Æ()
- Dim I As Integer, ii As Integer, e As Object
- Dim Search As String, IMG As Object, Span As Object, A As Object
- Search = InputBox("kd-55x8000g", "½Ð¿é¤Jn·j´Mªº¦r¦ê")
- If Search = "" Then MsgBox "¨S¦³½Ð¿é¤J......": End
- With CreateObject("InternetExplorer.Application")
- ' .Visible = True
- .Navigate "https://www.findprice.com.tw/"
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- .Document.GETELEMENTBYID("search").Value = Search '**¿é¤Jn·j´Mªº¦r¦ê
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- .Document.GETELEMENTBYID("tsbb").Click '**·j´MÁä
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Set A = .Document.form1.ALL.TAGS("tbody")
- If InStr(A(1).INNERTEXT, Search) = 0 Then '**¨S¦³·j´M¨ì
- MsgBox vbLf & A(1).INNERTEXT
- GoTo Xquit
- Else
- ¤u§@ªí¾ã²z
- Cells(1) = Trim(Split(A(1).INNERTEXT, ">")(0))
- Cells(1, 2) = "»ù®æ"
- Cells(1, 3) = "»¡©ú"
- End If
- I = 1
- NE:
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
- Set e = .Document.GETELEMENTBYID("tbContent").ALL.TAGS("TR")
- For ii = 1 To e.Length - 1
- With e(ii).ALL
- Set A = .TAGS("A")(0)
- If Not A Is Nothing Then
- Set IMG = A.ALL.TAGS("IMG")(0)
- Set Span = .TAGS("SPAN")
- If Not IMG Is Nothing And Span.Length > 0 Then
- If Span(0).CLASSNAME = "rec-price-20" Then
- I = I + 1
- Cells(I, "b") = Trim(Span(0).INNERTEXT)
- Cells(I, "C") = Trim(IMG.Title)
- ºô¸ô¹Ï¤ù IMG.Href
- Ex_ºô¶¸ê®Æ Cells(I, "a"), A.Href
- End If
- End If
- End If
- End With
- Next
- '**¤U¤@¶ '<a id="pg-next" href="/g/kd-55x8000g/?i=3">¤U¤@¶ ></a>
- For Each e In .Document.ALL.TAGS("A")
- If e.ID = "pg-next" Then
- e.Click '¤U¤@¶ («öÁä)
- GoTo NE '´`Àô¨ì¤U¤@¶
- End If
- Next
- Xquit:
- .Quit 'Ãö³¬ºô¶
- End With
- Range("b:b").Columns.AutoFit
- End Sub
- Private Sub ¤u§@ªí¾ã²z()
- ¹Ï¤ù¥Ø¿ý = ThisWorkbook.Path & "\°Ó«~¹Ï¤ù\"
- If Dir(¹Ï¤ù¥Ø¿ý, vbDirectory) = "" Then MkDir ¹Ï¤ù¥Ø¿ý '**¨S¦³¹Ï¤ù¥Ø¿ý«h«Ø¥ß¤§
- If Dir(¹Ï¤ù¥Ø¿ý & "*.*") <> "" Then Kill ¹Ï¤ù¥Ø¿ý & "\*.*" '**¹Ï¤ù¥Ø¿ý¤U¦³Àɮ׫h§R°£¤§
- ¹Ï¤ù¼Æ = 0
- Pictures.Delete '**§R°£¤u§@ªí¤Wªº¹Ï¤ù
- With Cells
- .Clear
- .Columns.AutoFit
- .Rows.AutoFit
- .WrapText = False
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- With Range("c:c")
- .ColumnWidth = 40
- .WrapText = True
- End With
- End Sub
- Private Sub Ex_ºô¶¸ê®Æ(Rng As Range, Href As String)
- With Rng
- .ColumnWidth = 15
- .RowHeight = 90
- End With
- With Pictures.Insert(¹Ï¤ù¦WºÙ) '**´¡¤J¹Ï¤ù
- .ShapeRange.LockAspectRatio = msoFalse '**¤£Âê©w¹Ï¤ùªºªø¼e¤ñ¨Ò
- .top = Rng.top
- .left = Rng.left
- .Height = Rng.Height
- .width = Rng.width
- ActiveSheet.Hyperlinks.Add Anchor:=.ShapeRange.Item(1), Address:=Href '***¶W³sµ²
- End With
- End Sub
- Private Sub ºô¸ô¹Ï¤ù(URL As String)
- Dim Xml As Object '¥Î¨Ó¨ú±oºô¶¸ê®Æ
- Dim Stream As Object 'As ADODB.stream '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
- On Error GoTo Url_err '³B²z¹Ï¤ùºô¶ªº¿ù»~
- Again:
- Set Xml = CreateObject("Microsoft.XMLHTTP")
- Set Stream = CreateObject("ADODB.stream")
- Xml.Open "GET", URL, 0
- Xml.send
- With Stream
- .Open
- .Type = 1
- .write Xml.ResponseBody
- ' If Dir(°Ó«~¹Ï¤ù) <> "" Then Kill °Ó«~¹Ï¤ù
- ¹Ï¤ù¦WºÙ = ¹Ï¤ù¥Ø¿ý & ¹Ï¤ù¼Æ & ".jpg"
- ¹Ï¤ù¼Æ = ¹Ï¤ù¼Æ + 1
- .SaveToFile (¹Ï¤ù¦WºÙ)
- .Close
- End With
- Set Xml = Nothing
- Set Stream = Nothing
- Exit Sub
- Url_err:
- URL = "https://th.bing.com/th/id/OIP.lmGYd5XOfu-zuoG1GZW-HAHaE8?w=256&h=171&c=7&o=5&dpr=1.2&pid=1.7"
- GoTo Again
- End Sub
½Æ»s¥N½X |
|