Python Tutorials | Web Scraping web tool - for starters
2014-08-30, 08:44 PM, (This post was last modified: 2014-08-31, 09:30 PM by IceMaker.)
#1
Hi guys,

Here some really simple tutorial about Web scraping with Python programming!

Take te code for Free, and you are be free for thanks me:)

Step 1:

This code is working with Python 2.7 with the IDLE (Python GUI) panel
try to figure it out with you own experiences!

Step 2:
See here directly the code: and do Copy - Paste

[hide]Give some Thanks for showing this code
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from bs4 import BeautifulSoup
import urllib2
import re

print "Python script for WebScrapping by Mrbagino"

url="https://www.your-destination-link.com"
page=urllib2.urlopen(url)
soup = BeautifulSoup(page.read())



line = "Postcode";

matchObj = re.match( r'postcode', line, re.M|re.I)
if matchObj:
   print "match --> matchObj.group() : ", matchObj.group()
else:
   print "No match!!"

searchObj = re.search( r'postcodes', line, re.M|re.I)

if searchObj:
   print "search --> searchObj.group() : ", searchObj.group()
else:
   print "Nothing found!!"



postcodes=soup.findAll('a', {'class':'view'})
line = "postcode"


// see below here save options, this can changes by every extension you like! //

text_file = open("opentext.txt", "w")
text_file.write("Purchase postcodes: %s" % postcodes)
text_file.close()

with open("opentext.txt", "w") as text_file:
    text_file.write("Purchase postcodes : {0}" .format(postcodes))
for eachpostcode in postcodes:
   print eachpostcode['href']+","+eachpostcode.string
[/hide]

See also here how to install the Libs behind the codes http://www.cpaelites.com/thread-32097-post-368796.html
Hoping you have learn somthing, enjoy it!

Peace Mrbagino
Reply
Share This Thread :

2014-09-07, 08:58 PM,
#2
Thanks for the contribution.

Any questions related to CPA belong here.
Before posting, make sure you are in the correct section.

I am temporarily absent due to family circumstances.

Reply
2014-09-10, 04:07 PM,
#3
Thanks DutchPride for your comment, in the future i like to learn other peeps more about programming!

Enjoy all, Peace!
Reply


Related Threads
Thread Author Replies Views Last Post
  Why customer complaints are occuring in Ecommerce Web Development? How to control it? sureshkumar 3 493 2017-07-03, 09:54 PM
Last Post: imrichard
  [GET] How To Generate Web Design Assets In Photoshop With Just One Click cindy2145 0 662 2017-04-30, 03:06 AM
Last Post: cindy2145
  Webmaster Digger 1.3 - The webmaster & web digger tool datagroove 1 1,120 2016-09-17, 06:21 PM
Last Post: datagroove
  Data Publisher - #1 Publisher Registration Tool datagroove 0 777 2016-04-30, 04:33 PM
Last Post: datagroove
  Looking for a web deeloper zakka33 0 728 2016-02-18, 11:45 PM
Last Post: zakka33





About Us | Contact Us | CPA Elites | Advertise | Stats

© 2013-2018 CPA Elites Ltd
Enhanced by MyBB and WallBB
Return to top