그래서 난 당신이 모든 인도의 상태를 볼 수 있습니다 왼쪽 창에서몇 가지 문제
http://202.54.31.7/citywx/localwx.php
그래서 인도의 날씨 웹 사이트를 긁어되었고, 당신이 그들 위에 마우스를 올려 경우에 당신이 도시를 선택할 수 있습니다/지구. 그래서 왼쪽 창에서 Delhi->safdarjung
을 선택하고 현지에이 페이지를 저장 : - 만이 정도
from BeautifulSoup import BeautifulSoup
import urllib, urllib2
imd_ind = urllib2.urlopen('http://202.54.31.7/citywx/localwx.php')
delhi_info = imd_ind.read()
open('delhi_info.html', 'w').write(delhi_info)
soup = BeautifulSoup(open('delhi_info.html'))
soup.prettify
인쇄 : -
<bound method BeautifulSoup.prettify of <html><head><title>Local Weather Forecast</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="MSHTML 5.00.2920.0" name="GENERATOR" /></head>
<frameset border="0" cols="330,611*" frameborder="NO" framespacing="0" rows="*"><frame name="menuFrame" noresize="noResize" src="menu.php" /><frame name="mainframe" src="http://202.54.31.7/citywx/city_weather1.php?id=42182" /></frameset></html>
>
내가 크롬에 로컬로 저장 페이지 "delhi_info.html"를 검사하면 반면에 , 나는 많은 정보 날짜, 온도, 흐린 날씨 등을 볼 수있다. (즉, 많이있다.)하지만 왜 BeautifulSoup 메쏘드를 통해 그들을 볼 수 없는가? 도와주세요
쓰기 위해 파일을 닫기 전에 파일을 열어서 일부 콘텐츠가 아직 버퍼링 중이며 아직 디스크에 쓰여지지 않은 것 같습니다. 대신 try :'open ('delhi_info.html', 'w')을 f : f.write (delhi_info)'로 사용하십시오. – isedev
감사합니다 isedev, 그래서 그것을 해결하기 위해해야합니까. Pls 도움 !!. – shalini
아니요, 'delhi_info'내용을 인쇄해도 같은 결과가 나옵니다. – ton1c