Skip to content

Instantly share code, notes, and snippets.

@avevlad
Forked from anonymous/parse.py
Created July 24, 2014 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avevlad/7256c6854e6b5bc55809 to your computer and use it in GitHub Desktop.
Save avevlad/7256c6854e6b5bc55809 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
class Parser:
def __init__(self):
self.fl()
def fl(self):
payload = {
'action': 'postfilter',
'pf_pro_only': '1'
}
r = requests.post("https://www.fl.ru/projects/", data=payload)
html_parse = BeautifulSoup(r.text)
for post_item in html_parse.findAll("div", {"class": "b-post"}):
data = self.getPostInfo(post_item)
self.setDb(data)
def getPostInfo(self, post_item):
post_href = post_item.find("a", {"class": "b-post__link"})
post_title = post_href.text
post_link = post_href["href"]
post_ld = post_link.split("/")[2]
return (
post_ld,
post_title,
post_link
)
def setDb(self, data):
print(data)
dog = Parser()
@avevlad
Copy link
Author

avevlad commented Aug 1, 2014

python 😕 python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment