Last active
June 29, 2016 04:07
-
-
Save sarathlal-old/90c95bf010be7fd19603b349f759ff9b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from bs4 import BeautifulSoup | |
| import urllib | |
| r = urllib.urlopen('http://192.168.1.64/test/120.html').read() | |
| soup = BeautifulSoup(r) | |
| title = soup.find("div", class_="row1 content conAddres").find("h3").string | |
| author = soup.find("div", class_="row1 content conAddres").find("h4").find("a").string | |
| phone = soup.find("div", class_="row1 content conAddres").find("div", class_="row1 phoneNo").find("p").string | |
| email = soup.find("div", class_="row1 content conAddres").find("div", class_="row1 email").find("p").string | |
| postdate = soup.find("div", class_="conAddressRight").find("span", class_="postDate1").string | |
| qty1 = soup.find("div", class_="conAddressRight").find("div", class_="row1 quantity").find("span").find("p").string | |
| qty = qty1[23:-1] | |
| desc = soup.find("div", class_="row1 detailContent Dmain").find("p", id='long_desc').string | |
| img = soup.find("div", class_="row1 detailPic").find("img")['src'] | |
| addressdiv = soup.find("div", class_="row1 content conAddres").find("h4") | |
| addressdiv.find('a').replaceWith('') | |
| addstring = addressdiv.text | |
| wholeadd = addstring[2:] | |
| addlist = wholeadd.split(",") | |
| address = [] | |
| for item in addlist: | |
| item = item[1:] | |
| address.append(item) | |
| district = address.pop() | |
| fulladdress = ",".join(str(i) for i in address) | |
| print district | |
| print fulladdress | |
| price1 = soup.find("div", class_="conAddressRight").find("div", class_="row1 quantity").find("span") | |
| price1.find('p').replaceWith('') | |
| price2 = price1.text | |
| price = price2[11:-3] | |
| print price | |
| sep = "," | |
| f = open('jan.csv','w') | |
| f.write(str(title)+sep+str(author)+sep+str(phone)) | |
| f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment