level 6
woohaha
楼主
我有一个表格,内容如下:
html = '<table bgcolor="#CCCCCC" border="0" cellpadding="6" cel
lsp
acing="1" width="100%">
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<th></th>
<th>代理</th>
<th>端口</th>
<th>国家</th>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">1</td>
<td>118-163-44-224.hinet-ip.hinet.net</td>
<td width="60">3128</td>
<td width="60">TW</td>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">2</td>
<td>124.195.8.65</td>
<td width="60">8080</td>
<td width="60">ID</td>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">3</td>
<td>110.77.250.190</td>
<td width="60">8080</td>
<td width="60">TH</td>
</tr>
</table>'

我想用bs4处理,将表格的内容以输出成一个dict,格式如下
data = {'server':['118-163-44-224.hinet-ip.hinet.net','124.195.8.65','110.77.250.190'],'port':['3128','8080','8080'],'location':['TW','ID','TH']}
我试来试去都只能得到一个list,求敎。
2013年07月03日 08点07分
1
html = '<table bgcolor="#CCCCCC" border="0" cellpadding="6" cel
lsp
acing="1" width="100%">
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<th></th>
<th>代理</th>
<th>端口</th>
<th>国家</th>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">1</td>
<td>118-163-44-224.hinet-ip.hinet.net</td>
<td width="60">3128</td>
<td width="60">TW</td>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">2</td>
<td>124.195.8.65</td>
<td width="60">8080</td>
<td width="60">ID</td>
</tr>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor='#ffffff';" onmouseover="this.style.backgroundColor='#ffcc00';">
<td width="30">3</td>
<td>110.77.250.190</td>
<td width="60">8080</td>
<td width="60">TH</td>
</tr>
</table>'

我想用bs4处理,将表格的内容以输出成一个dict,格式如下data = {'server':['118-163-44-224.hinet-ip.hinet.net','124.195.8.65','110.77.250.190'],'port':['3128','8080','8080'],'location':['TW','ID','TH']}
我试来试去都只能得到一个list,求敎。
