我需要从具有csv / excel身份验证的网站中提取下表。
我有相应的网址和凭据。
请需要一些主意。
嗨
更新同一问题的状态
我编写了以下代码以获取表的数据
$URL = ""
[string]$Username = ""
[string]$Password = ""
$passwd = $Password
$user= $Username
$secpasswd = ConvertTo-SecureString $passwd -AsPlainText -Force
$ltmCreds = New-Object System.Management.Automation.PSCredential ($user, $secpasswd)
# reading website data:
$data = Invoke-WebRequest -Uri $URL -Credential $ltmCreds
$rawdata=$data.Content
$table_match=[regex]::Matches($rawdata,'<TABLE BORDER=0[\s\S]*<\/table>')
现在数据如下所示在“ $ table_match”中显示
Groups : {0}
Success : True
Name : 0
Captures : {0}
Index : 3699
Length : 306722
Value : <TABLE BORDER=0 CLASS='data'>
<TR><TH CLASS='data'>Host</TH><TH CLASS='data'>Service</TH><TH CLASS='data'>% Time OK</TH><TH CLASS='data'>% Time Warning</TH><TH CLASS='data'>%
Time Unknown</TH><TH CLASS='data'>% Time Critical</TH><TH CLASS='data'>% Time Undetermined</TH></TR>
<tr CLASS='dataOdd'><td CLASS='dataOdd'><a href='avail.cgi?host=xxxxxx.xx.xxx.com&show_log_entries&t1=1564144321&t2=1566822721&backtrack=4&as
sumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning=yes&initialassumedhoststate=0&initialassumedservicestate=0&show_log_entri
es&showscheduleddowntime=yes'>xxxxxx.xx.xxx.com</a></td><td CLASS='dataOdd'><a href='avail.cgi?host=xxxxxx.xx.xxx.com&service=UK-ASDA
-Internal+-+XXXXXX+-XXXXX&t1=1564144321&t2=1566822721&backtrack=4&assumestateretention=yes&assumeinitialstates=yes&assumestatesduringnotrunning
=yes&initialassumedhoststate=0&initialassumedservicestate=0&show_log_entries&showscheduleddowntime=yes'>UK-ASDA-Internal - XXXXXXX
-XXXXXX</a></td><td CLASS='serviceOK'>99.989% (99.989%)</td><td CLASS='serviceWARNING'>0.000% (0.000%)</td><td CLASS='serviceUNKNOWN'>0.000%
(0.000%)</td><td class='serviceCRITICAL'>0.011% (0.011%)</td><td class='dataOdd'>0.000%</td></tr>
..................
..............
...
</table>
需要逐行将其放入excel。
请为此提供帮助。
谢谢