저는 파이썬을 처음 사용하고 웹 스크 레이 핑에 관한 도움을 원합니다.웹 스크래핑 ~ 파이썬
나는 그것에 파이썬이있는 라즈베리 Pi3을 가지고 있는데, 웹 페이지에서 BeautifulSoap을 사용하여 데이터를 추출하고 타임 스탬프가있는 텍스트 파일에 쓰고 싶습니다. 그래서 파이를 24x7로 유지하고 싶습니다. 특정 시간 간격 후에 자신을 반복하므로 나중에 이러한 값을 사용하여 그래프를 만들 수 있습니다.
시작, 난>
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("https://172.30.83.14/bsnlfup/usage.php")
bsObj = BeautifulSoup(html.read());
print(bsObj.td)"
을 시도하고 출력은
<td align="right">
<a href="usage.php"><img alt="" border="0" height="152" src="images/fuph.jpg" width="100%"/></a>
데이터가 TD 태그 안에 포함되었다거나 다른 일이었다, 그러나 많은 TD 태그에 있었다 페이지, 그래서 그것은 작동하지 않았고 내가 어떻게 txt 파일에 데이터를 작성하게 몰라요.
난 그냥 즉 내가에 78.647GB을 수출하고 싶었다 "고 (FUP - 원본)와 함께 남은 다운로드 속도"후 태그의 데이터를 내보낼 원 소스 -<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="No-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="keywords" content="High-Speed, Broadband, IPTV, Internet, VoIP">
<meta name="description" content="Leading provider of high-speed communication services.">
<link rel="stylesheet" type="text/css" href="css/npm.css">
<title>BSNL BROADBAND</title>
<script language="Javascript" type="text/javascript" src="js/npmcommon.js"></script>
</head>
<body onload="TINIT();" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0" bgcolor="#ffffff">
<div class="portalheader" align="left">
<table style="width: 100%;" border="0" cellspacing="0" cellpadding="0" bgcolor="white">
<tr>
<td align="right">
<a href="usage.php"><img src="images/fuph.jpg" alt="" border="0" height="152" width="100%"></a>
</td>
</tr>
<tr>
<td style="width: 100%; height: 10px; background-color: rgba(29, 117, 182, 1);"></td>
</tr>
</table>
</div>
<div class="serviceservlet">
<table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="width: 165px; vertical-align: top; background-color: rgb(f, f, f);">
<table border="0" cellpadding="0" cellspacing="0" width="165">
<tbody>
<tr>
<td colspan="3" height="48">
<br>
</td>
</tr>
</tbody>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="165">
<tbody>
<tr>
<td style="width: 10px;">
<br>
</td>
</tr>
</tbody>
</table>
</td>
<td valign="top" width="100%">
<table style="width: 100%; height: 204px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr></tr>
<tr>
<td colspan="2">
<font size="-1" face="Verdana, Arial, Helvetica, sans-serif">
<br>
<b>
You are logged in as
'[email protected]' at 117.000.000.000.
<br>
<br>
</b>
<br>
<br>
</font>
<!--Display the available metered time usage stats-->
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<noscript>
<tr>
<td>
<a href="help.php#Java_script" target="new">
<font color="#FF0000">
<u>You must have JavaScript enabled in order to view usage stats.</u>
</font>
</a>
<br>
<br>
</td>
</tr>
</noscript>
<tr>
<td colspan="4">
<font color="#0A63BF">
<b> </b>
</font>
</td>
</tr>
<tr>
<td>
<i></i>
</td>
</tr>
</table>
<br>
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<noscript>
<tr>
<td>
<a href="help.php#Java_script" target="new">
<font color="#FF0000">
<u>You must have JavaScript enabled in order to view usage stats.</u>
</font>
</a>
<br>
<br>
</td>
</tr>
</noscript>
<tr>
<td colspan="7">
<font color="#0A63BF">
<b> </b>
</font>
</td>
</tr>
<tr align="left">
<th>Download Remaining with High(FUP-original)Speed </th>
</tr>
<tr align="left">
<td>78.647 GB</td>
<td>
<a href="top_up.php?service=HS-I-H-50MB-90GB-10MB-B-M&timeMetered=false"><img name="addBytes" src="images/btn1.png" border="0" alt="[AddBytes]" title="Top up volume quota"></a>
</td>
</tr>
<tr height="10">
<td>
<font color="#0A63BF"></font>
</td>
</tr>
</table>
<p>
<p></p>
</p>
</td>
<td style="width: 10px; background-color: rgb(f,f,f);">
<br>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="portalfooter" align="left">
<td style="vertical-align: top;">
<table style="width: 100%; height: 86px;" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td colspan="3" rowspan="1" style="background-color: rgb(f, f, f);">
<br>
</td>
</tr>
<tr valign="top">
<td style="width: 165px; height: 10px;" border="0">
<br>
</td>
<td class="npm10Text" height="10">
<br>
<br>
<p align="right">2014 BSNL . All rights reserved.</p>
<br>
<br>
</td>
<td align="right" style="vertical-align: middle;"></td>
</tr>
<tr>
<td colspan="3" rowspan="1" style="background-color: rgba(29, 117, 182, 1);">
<br>
</td>
</tr>
</tbody>
</table>
</td>
</div>
</body>
</html>
HTML 타임 스탬프가있는 텍스트 파일 그런 다음 시간 간격을두고 반복하고 동일한 텍스트 파일에 내 보낸 항목을 다시 추가하십시오.
요요 요소에 대한 XPath를 얻으려면 Chrome 개발자 도구와 같은 것을 사용하십시오. 당신이 분석하고 싶습니다. – MattDMo