دنبال کننده ها

۱۳۹۶ دی ۱۲, سه‌شنبه

html - Urllib2 in python: why is it not returning the webpage formatting and not the actual data

[ad_1]



can someone tell me why, when I run this code:



import urllib2
for i in range(1,2):
id_name ='AP' + str(":05d".format(i))
web_page = "http://aps.unmc.edu/AP/database/query_output.php?ID=" + id_name
page = urllib2.urlopen(web_page)
html = page.read()
print html


It returns:



<html>
<head>
<title>detailed information</title>
<style type="text/css">
H1 font-family:"Time New Roman", Times; font-style:bold; font-size:18pt; color:blue
H1text-align:center
Pfont-family:"Time New Roman", Times; font-style:bold; font-size:14pt; line-height:20pt
Ptext-align:justify;margin-left:0px; margin-right:0px;color:blue
/bodybackground-image:url('sky.gif')
/
A:linkcolor:blue
A:visitedcolor:#996666
</style>
</head>
<H1>Antimicrobial Peptide APAP00001</H1>
<html>
<p style="margin-left: 400px; margin-top: 4; margin-bottom: 0; line-height:100%">
<b>
<a href = "#" onclick = "window.close(self)"><font size="3" color=blue>Close this window
</font> </a>
</b>
</p>
</p>
</body>
</html>


And not the actual data on the page (http://aps.unmc.edu/AP/database/query_output.php?ID=00001) (e.g. net charge, length)?



If I edit this code slightly somehow, is it possible to return all of the information on the page (e.g. the information about net charge, length etc), and not just information about how the page is formatted?



Thanks




[ad_2]

لینک منبع