Scraping a website using Python and printing to a file conflict -


i trying scrape data website , write extracted data in file. related question here.

in answer there function:

def get_books(data):     soup = beautifulsoup(data)      title in soup.select("div.zg_itemimmersion div.zg_title a"):         print title.get_text(strip=true) 

and whole thing works great. but, add line write book title in file, see not book titles displayed on screen. if there conflict somewhere or there time sensitive function somewhere.

the code behave strangely alone line:

def get_books(data):     soup = beautifulsoup(data)     f = open('myfile','a')     title in soup.select("div.zg_itemimmersion div.zg_title a"):         print title.get_text(strip=true)         f.write(title.get_text(strip=true))     f.close() 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -