BeautifulSoup help !!

Navneet Siddhant desolate.soul.me at gmail.com
Thu Oct 6 13:00:38 EDT 2016


On Thursday, October 6, 2016 at 8:52:18 PM UTC+5:30, Navneet Siddhant wrote:
> So I've just started up with python and an assignment was given to me by a company as an recruitment task.
> 
> I need to web scrap the coupons of all the websites available on http://www.couponraja.in and export it to csv format. 
> The details which I need to be present in the csv are the coupon title , vendor , validity , description/detail , url to the vendor , image url of the coupon.
> 
> I have gone through many tutorials on beautifulsoup and have a beginners understanding of using it. Wrote a code as well , but the problem Im facing here is when i collect info from the divs which contains all those info , Im getting it in with all the html tags and the info is clustered. 
> 
> Code m using :
> 
> import requests
> from bs4 import BeautifulSoup
>  
> url = "https://www.couponraja.in/amazon"
> r = requests.get(url)
> soup = BeautifulSoup(r.content)
> g_data = soup.find_all("div", {"class": "nw-offrtxt"})
> for item in g_data:
>     print item.contents
> 
> also will need help on how to export the info to csv format , I just know I need to import csv then write the information to a csv file.
> But not getting through on how to achieve that.
> 
> Any help will be appreciated.

Thanx for the support Steve . N yes you can call me Sid ..  :) . . .. 


I guess I shouldnt have mentioned as this was a recruitment task. If needed I can post a screenshot of the mail I got which says I can take help from anywhere possible as long as the assignment is done. Wont be simply copying pasting the code as question related to the same will be asked in the interview.
I just need a proper understanding as to what I need to do to get the results.
Also how to export the result to csv format.



More information about the Python-list mailing list