Home > Software engineering >  Web page data into EXCEL spreadsheet, ask for help!
Web page data into EXCEL spreadsheet, ask for help!

Time:09-23

Web data into EXCEL spreadsheet, please grab the code! Haven't learned these knowledge, enthusiastic friends to help, thank you first!

Copy the address: http://pan.baidu.com/s/1eRTNr94
Collect web: http://www.17500.cn/pub/sjh.htm

CodePudding user response:

http://pan.baidu.com/s/1c2yZ1wk

 
Sub import ()
With HTTP url="http://www.17500.cn/pub/sjh.htm"
Dim XmlHttp As Object, stime, ntime
The Set XmlHttp=CreateObject (" Microsoft. XmlHttp ")
XmlHttp. Open "GET", take the HTTP url, True
XmlHttp. Send
Stime=Now
While XmlHttp. ReadyState & lt;> 4

DoEvents
Ntime=Now

If DateDiff (" s ", stime, ntime) & gt; 3 Then MsgBox "under the network is not very good, try again" : the Exit Sub
Wend
Access to remote web source=StrConv (XmlHttp. ResponseBody vbUnicode)
The Set XmlHttp=Nothing

Starting position=InStr (for remote web site source code, "3 d") + 3
End position=InStr (access to remote web site source code, "period of commissioning")
Name=Mid (for remote web site source code, start and end position - starting position)


Starting position=InStr (for remote web site source code, "3 commissioning & lt;/div> & lt; Font color=red> & lt; B>" 29) +
End position=InStr (for remote web site source code, & lt;"/b> & lt;/font> & lt;/a> & lt; A href=https://bbs.csdn.net/pub/sjh.htm ")
Nper=Mid (for remote web site source code, start and end position - starting position)


Cells (7, 8)=stage name
Cells (9, 7)=Mid (nper, 1, 1)
Cells (9, 8)=Mid (nper, 2, 1)
Cells (9, 9)=Mid (nper, 3, 1)
End Sub

CodePudding user response:

reference 1st floor qq574221329 response:

http://pan.baidu.com/s/1c2yZ1wk
 
Sub import ()
With HTTP url="http://www.17500.cn/pub/sjh.htm"
Dim XmlHttp As Object, stime, ntime
The Set XmlHttp=CreateObject (" Microsoft. XmlHttp ")
XmlHttp. Open "GET", take the HTTP url, True
XmlHttp. Send
Stime=Now
While XmlHttp. ReadyState & lt;> 4

DoEvents
Ntime=Now

If DateDiff (" s ", stime, ntime) & gt; 3 Then MsgBox "under the network is not very good, try again" : the Exit Sub
Wend
Access to remote web source=StrConv (XmlHttp. ResponseBody vbUnicode)
The Set XmlHttp=Nothing

Starting position=InStr (for remote web site source code, "3 d") + 3
End position=InStr (access to remote web site source code, "period of commissioning")
Name=Mid (for remote web site source code, start and end position - starting position)


Starting position=InStr (for remote web site source code, "3 commissioning & lt;/div> & lt; Font color=red> & lt; B>" 29) +
End position=InStr (for remote web site source code, & lt;"/b> & lt;/font> & lt;/a> & lt; A href=https://bbs.csdn.net/pub/sjh.htm ")
Nper=Mid (for remote web site source code, start and end position - starting position)


Cells (7, 8)=stage name
Cells (9, 7)=Mid (nper, 1, 1)
Cells (9, 8)=Mid (nper, 2, 1)
Cells (9, 9)=Mid (nper, 3, 1)
End Sub








The teacher hello: this is my own to piece together a way, and you write really that good? Should I use the stable, "thank you! @

CodePudding user response:

 Private Sub CommandButton1_Click () 
Dim Ar $, Arr, url
Url="http://www.17500.cn/pub/sjh.htm" 'link
With CreateObject (" Microsoft. XMLHTTP ")
. Open the "GET", url, False 'to grab the link
. Send
Ar=StrConv (responseBody, vbUnicode) 'transformation format
Ar=Left (Split (Ar, "3 d") (1), 39) 'find commissioning date data
Arr=Split (Ar, "period of commissioning") 'load array
'if? Like rigth (arr (0), 3)=false then the current trial number has not been updated! "" : end
Ar=Right (Arr (1), 3)
[g10: i10]=Array (Val (Left (Ar, 1)), Val (Mid (Ar, 2, 1)), Val (Ar, 1)) (Right) 'fill in the current trial number!
The Close
End With
End Sub

CodePudding user response:

Look under the
Which almost
2 l estimate is to use easy language introductory
Actually when variable in Chinese...
Can you behind that can also
Fill to EXCEL spreadsheets.
  •  Tags:  
  • VBA
  • Related