Pitmairen wrote: > I want to make a program that get info from a website and prints it out > in a txt file. > > I made this: > > import urllib > f = urllib.urlopen("http://www.imdb.com/title/tt0407304/") > s = f.read() > k = open("test.txt","w") > k.write(s) > k.close() > f.close() > > That saves all the html code into the test.txt file. But if i for > example only want the genre, plot outline and Cast overview to be > written to the txt file. How can i do that? > > > And another problem i have: > > If the txt file i want the information to be saved in already have some > text saved in it. How can i save the info from the website between the > text that was there before? > > for example: > > blablablablablablablabla > blablablablablablablabla > blablablablablablablabla > (inset info from website here) > blablablablablablablabla > blablablablablablablabla > blablablablablablablabla >
to get a text file that looks like your web page, stripped of markup, look at "lynx -dump" or "w3m -dump" ( i think links2 does the same). else: http://groups.google.com/group/comp.lang.python/browse_frm/thread/f899b120bd9bf821/1a9a5fe2bc92e00f?q=html&_done=%2Fgroup%2Fcomp.lang.python%2Fsearch%3Fgroup%3Dcomp.lang.python%26q%3Dhtml%26qt_g%3D1%26searchnow%3DSearch+this+group%26&_doneTitle=Back+to+Search&&d http://groups.google.com/group/comp.lang.python/browse_frm/thread/7b411613ef23f62d/adb74a1bb1355632?q=html+group:comp.lang.python&_done=%2Fgroups%3Fq%3Dhtml+group:comp.lang.python%26start%3D10%26hl%3Den%26lr%3D%26ie%3DUTF-8%26safe%3Doff%26num%3D10%26as_drrb%3Db%26as_mind%3D1%26as_minm%3D10%26as_miny%3D2004%26as_maxd%3D16%26as_maxm%3D2%26as_maxy%3D2005%26&_doneTitle=Back+to+Search&&d -- http://mail.python.org/mailman/listinfo/python-list