Posts

Showing posts from June, 2020

How To Crawl Coupon Sites With Python

Image
In this post, I will show you how to use Python and LXML to crawl coupons and deals from coupon sites. The purpose of this post is to help users write crawlers with Python. To demo this, I will crawl coupons from couponannie.com and couponmonk.us. Example 1 Let us start with couponannie.com first. Let us first import the following two libraries.. import requests import lxml.html Most of the coupon sites have thousands of coupon pages. Most of the times, these pages are per company or site. These pages are structured templates. Therefore when we write a crawler for one coupon page, then it should work for all the coupon pages. In the case of couponannie also, this is the case. Let us pick the following url couponannie.com/stores/linkfool and extract the coupons and its related information. url = 'https://www.couponannie.com/stores/linkfool' We will use requests to get the content of above page as shown below. obj = requests.get(url) Let us convert the data in to