Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import flask, flask.views
- from flask import request
- import os
- import requests
- from bs4 import BeautifulSoup
- import re
- app = flask.Flask(__name__)
- class View(flask.views.MethodView):
- def get(self):
- return flask.render_template('index.html')
- def getPhone(n):
- n=0
- while n<6:
- if re.search(regNum,contactData[n].text) and re.search(regAddr,contactData[n].text):
- number = contactData[n].text
- flask.flash(firmName)
- flask.flash(jobTitle)
- flask.flash(jobCity)
- flask.flash(number)
- break
- elif re.search(regNum,contactData[n].text):
- number = contactData[n].text
- flask.flash(firmName)
- flask.flash(jobTitle)
- flask.flash(jobCity)
- flask.flash(number)
- break
- elif re.search(regNum,moreSoup.find_all('span',{'class':'nowrap'})[n].text):
- number = soup.find_all('span',{'class':'nowrap'})[n].text
- flask.flash(firmName)
- flask.flash(jobTitle)
- flask.flash(jobCity)
- flask.flash(number)
- break
- else:
- n+=1
- def getPhoneAlt(v):
- v=0
- while v<29:
- number = moreSoup.find_all('li')[v].text
- if re.match(regNum,number):
- flask.flash(number)
- break
- else:
- v+=1
- def googShortUrl(url):
- post_url = 'https://www.googleapis.com/urlshortener/v1/'+url
- payload = {'longUrl': url}
- headers = {'content-type':'application/json'}
- r = requests.post(post_url, data=json.dumps(payload), headers=headers)
- text = r.content
- text = json.loads(text)
- return (text['id'])
- def post(self):
- what = flask.request.form['what']
- where = flask.request.form['where']
- jobType = flask.request.form['jt']
- salary = flask.request.form['salary']
- fromage = flask.request.form['fromage']
- i=0
- while i<10:
- indeedSite = 'http://www.indeed.com/jobs?as_and='+what+'&as_phr=&as_any=&as_not=&as_ttl=&as_cmp=&jt='+jobType+'&st=&sr=directhire&salary='+salary+'&radius=25&l='+where+'&fromage='+fromage+'&limit=10&sort=&psf=advsrch'
- r = requests.get(indeedSite)
- soup = BeautifulSoup(r.content)
- g_data = soup.find_all('div', {'class': 'row'})
- for item in g_data:
- try:
- firmName = item.find_all('span',{'class':'company'})[0].text
- jobTitle = item.find_all('a',{'target':'_blank'})[0].text
- jobCity = item.find_all('span',{'class':'location'})[0].text
- jobCityPlus = re.sub(', ','+',jobCity)
- firmNamePlus = re.sub("\'",'',firmName)
- firmNamePlus = re.sub(' ','+',firmName)+'+'
- bingSearch = 'http://www.bing.com/search?q='+firmNamePlus+jobCityPlus
- info = requests.get(bingSearch)
- moreSoup = BeautifulSoup(info.content)
- contactData = moreSoup.find_all('div',{'class':"b_factrow"})
- number = contactData[0].text
- if getPhone(0) is not None:
- getPhone(0)
- else:
- getPhoneAlt(0)
- flask.flash(firmName)
- flask.flash(jobCity)
- flask.flash(jobTitle)
- flask.flash(number)
- for link in item('a',href=re.compile('^/rc/clk\?jk=|^.*clk\?|^.*\?r=1')):
- source = 'http://www.indeed.com'+link.get('href')
- googShortUrl(source)
- flask.flash(source)
- except:
- pass
- i+=10
- return self.get()
- app.add_url_rule('/',
- view_func=View.as_view('main'),
- methods=['GET','POST'])
- app.debug = True
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement