Пример #1
0
def get_facebook_token(email, password):
	MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; en-gb; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.16 Safari/535.19"
	FB_AUTH_URL = "https://www.facebook.com/v2.6/dialog/oauth?redirect_uri=fb464891386855067%3A%2F%2Fauthorize%2F&display=touch&state=%7B%22challenge%22%3A%22IUUkEUqIGud332lfu%252BMJhxL4Wlc%253D%22%2C%220_auth_logger_id%22%3A%2230F06532-A1B9-4B10-BB28-B29956C71AB1%22%2C%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A%22sfvc_auth%22%7D&scope=user_birthday%2Cuser_photos%2Cuser_education_history%2Cemail%2Cuser_relationship_details%2Cuser_friends%2Cuser_work_history%2Cuser_likes&response_type=token%2Csigned_request&default_audience=friends&return_scopes=true&auth_type=rerequest&client_id=464891386855067&ret=login&sdk=ios&logger_id=30F06532-A1B9-4B10-BB28-B29956C71AB1&ext=1470840777&hash=AeZqkIcf-NEW6vBd"
	
	rb = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="html5lib")
	
	try:
		# Read Facebook cookies
		cookies_file = open(parent_folder + "cookies.pckl", "rb")
		cookies = pickle.load(cookies_file)
		rb.session.cookies = cookies
		cookies_file.close()
		rb.open(FB_AUTH_URL)
	except IOError:
		# Facebook login
		rb.open(FB_AUTH_URL)
		login_form = rb.get_form()
		login_form["pass"] = password
		login_form["email"] = email
		rb.submit_form(login_form)
	        
	# Get token
	auth_form = rb.get_form()
	rb.submit_form(auth_form, submit=auth_form.submit_fields["__CONFIRM__"])
	access_token = re.search(r"access_token=([\w\d]+)", rb.response.content.decode()).groups()[0]
	
	return access_token
Пример #2
0
def wigle_print(username, password, netid):
    browser = robobrowser.RoboBrowser(history=True)
    browser.open('http://wigle.net')
    req_data = urllib.parse.urlencode({
        'credential_0': username,
        'credential_1': password
    })
    browser.open('https://wigle.net/gps/gps/main/login', req_data)

    params = {}
    params['netid'] = netid

    req_param = urllib.parse.urlencode(params)
    resp_url = 'http://wigle.net/gps/gps/main/confirmquery/'
    resp = browser.open(resp_url, req_param).read()
    map_lat = 'N/A'
    map_lon = 'N/A'
    r_lat = re.findall(r'maplat=.*\&', resp)

    if r_lat:
        map_lat = r_lat[0].split('&')[0].split('=')[1]
    r_lon = re.findall(r'maplon=.*\&', resp)

    if r_lon:
        map_lon = r_lon[0].split
    print('[-] Lat: {} Long: {}'.format(map_lat, map_lon))
Пример #3
0
def get_access_token():
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)

    f = s.get_form()

    print(
        'É necessário que você informe seu login do facebook para conectar ao Tinder:'
    )
    email = input('Email: ')
    password = input('Senha: ')

    f["pass"] = password
    f["email"] = email

    access_token = ''
    while access_token == '':
        try:

            s.submit_form(f)

            f = s.get_form()
            s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])

            access_token = re.search(r"access_token=([\w\d]+)",
                                     s.response.content.decode()).groups()[0]

        except:
            print('Falha ao acessar, tentando novamente')
            acess_token = ''

    return access_token
Пример #4
0
    def get_access_token(self):
        """returns access token from facebook"""

        # Create a robobrowser instantiation
        brow = robobrowser.RoboBrowser(
            user_agent=self.user_agent,
            parser="lxml")
        brow.open(self.fb_auth)

        # Submit login form
        _form = brow.get_form()
        _form['pass'] = self.password
        _form['email'] = self.email
        brow.submit_form(_form)

        # Click the 'ok' button on the dialog informing you that you have
        # already authenticated with the Tinder app
        _form = brow.get_form()
        brow.submit_form(_form, submit=_form.submit_fields['__CONFIRM__'])

        # Get access token from the HTTP response
        try:
            self.access_token = re.search(
                r"access_token=([\w\d]+)",
                brow.response.content.decode()).groups()[0]
        except NameError:
            print('[!] Cann\'t retreive access token')
            self.access_token = " "

        return self.access_token
Пример #5
0
def get_auth_code(url):
    import robobrowser
    br = robobrowser.RoboBrowser()
    br.open(url)
    form = br.get_form(id=0)
    if form is None:
        raise ValueError('No form! Do you have the right client id?')
    print('If you registered using google please navigate to\n'
          'the url below and leave email and password blank.')
    print()
    print(url)
    print()
    print(form)
    print()
    print('protocols.io OAuth form')
    e = form['email'].value = input('Email: ')
    p = form['password'].value = getpass()
    if e and p:
        br.submit_form(form)
        params = dict(parse.parse_qsl(parse.urlsplit(br.url).query))

    elif (not e or not p) or 'code' not in params:
        print('If you are logging in via a 3rd party services\n'
              'please paste the redirect url in the prompt')
        manual_url = input('redirect url: ')
        params = dict(parse.parse_qsl(parse.urlsplit(manual_url).query))
        if 'code' not in params:
            print('No auth code provided. Exiting ...')
            sys.exit(10)

    code = params['code']
    return code
Пример #6
0
def get_facebook_access_token(email, password):
    '''
    Gets Facebook access token using email and password.

    :param email: Facebook username: email.
    :param password: Facebook password.
    '''
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser='lxml')
    s.open(FACEBOOK_AUTH)
    f = s.get_form()
    f['pass'] = password
    f['email'] = email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
        access_token = re.search(r"access_token=([\w\d]+)",
                                 s.response.content.decode()).groups()[0]
        return access_token
    except Exception as ex:
        return {
            'error':
            'access token could not be retrieved. Check your username and password.',
            'exception': str(ex)
        }
Пример #7
0
def _get_fb_token(fb_email: str, fb_password: str) -> str:
    """
    Gets an access token from a username and password from facebook.

    :param fb_email: The user's email
    :param fb_password: The user's password

    :return: Returns an access token
    """

    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH_URL)
    f = s.get_form()
    f["pass"] = fb_password
    f["email"] = fb_email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields["__CONFIRM__"])
        access_token = re.search(r"access_token=([\w\d]+)",
                                 s.response.content.decode()).groups()[0]
        return str(access_token)
    except Exception as ex:
        raise ValueError(
            "access token could not be retrieved. Check your username and password. "
            "Official error: %s" % ex)
Пример #8
0
    def get_facebook_token(self, email, password, parent_folder):

        rb = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT,
                                     parser="html5lib")

        try:
            # Read Facebook cookies
            cookies_file = open(parent_folder + "cookies.pckl", "rb")
            cookies = pickle.load(cookies_file)
            rb.session.cookies = cookies
            cookies_file.close()
            rb.open(FB_AUTH_URL)

        except IOError:
            # Facebook login
            rb.open(FB_AUTH_URL)

            login_form = rb.get_form()
            login_form["pass"] = password
            login_form["email"] = email
            rb.submit_form(login_form)

        # Get token
        auth_form = rb.get_form()
        rb.submit_form(auth_form,
                       submit=auth_form.submit_fields["__CONFIRM__"])
        access_token = re.search(r"access_token=([\w\d]+)",
                                 rb.response.content.decode()).groups()[0]

        return access_token
Пример #9
0
def to_api(title, novel_id, author, novel_type, content, date):
    browser = robobrowser.RoboBrowser(history=True)
    url = 'http://apanr.net/'
    # open anyview a panel
    browser.open(url)
    # login form
    login_form = browser.get_form(id='log-in')
    login_form['account'].value = 'tengshan2008'
    login_form['password'].value = '8443658y'
    browser.submit_form(login_form)
    # access account
    open_account = browser.find(href='/account')
    browser.follow_link(open_account)
    # upload form
    upload_form = browser.get_form()
    # add upload action field
    upload_action_str = '\<input type="hidden" name="action" value="upload_file_post" \/\>'
    upload_action = robobrowser.forms.fields.Input(upload_action_str)
    upload_form.add_field(upload_action)
    # add upload file field
    # path = BASE_DIR + title + ".txt"
    path = os.path.join(BASE_DIR, title + ".txt")
    with open(path, 'w', encoding='utf-8') as f:
        f.writelines([
            "标题:" + title + "\n", "作者:" + author + "\n",
            "类型:" + novel_type + "\n", "日期:" + date + "\n", content + "\n"
        ])
    with open(path, 'r', encoding='utf-8') as f:
        upload_form['file_to_upload'].value = f
        browser.submit_form(upload_form)
Пример #10
0
def get_fb_access_token(email, password):
    browser = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT,
                                      parser="lxml")
    browser.open(url_auth)
    form = browser.get_form()
    form["pass"] = password
    form["email"] = email
    browser.submit_form(form, submit=form['login'])

    try:
        if browser.get_form(id="platformDialogForm") != None:
            formPermissions = browser.get_form(id="platformDialogForm")
            browser.submit_form(formPermissions,
                                submit=formPermissions['__CONFIRM__'])

        access_token = re.search(r"access_token=([\w\d]+)",
                                 browser.response.content.decode()).groups()[0]

        return access_token

    except Exception as e:
        print(
            "Access Token could not be retrieved. Check your username and password."
        )
        print("Official error: %s" % e)
        return {
            "error":
            "Access Token could not be retrieved. Check your username and password."
        }
Пример #11
0
def get_facebook_access_token(facebook_email, facebook_password):
    """Obtain a facebook user token.
    I copied it from github, however I lost the link.

    :param facebook_email: your facebook email
    :param facebook_password: your facebook password

    :return: access token
    """
    browser = robobrowser.RoboBrowser(user_agent=globals.USER_AGENT,
                                      parser="lxml")
    browser.open(globals.FB_AUTH_LINK)
    form = browser.get_form()
    form["pass"] = facebook_password
    form["email"] = facebook_email
    browser.submit_form(form)
    form = browser.get_form()
    try:
        browser.submit_form(form, submit=form.submit_fields['__CONFIRM__'])
        access_token = re.search(r"access_token=([\w\d]+)",
                                 browser.response.content.decode()).groups()[0]
        return access_token
    except requests.exceptions.InvalidSchema as browserAddress:
        access_token = re.search(r"access_token=([\w\d]+)",
                                 str(browserAddress)).groups()[0]
        return access_token
    except Exception as ex:
        print(
            "access token could not be retrieved. Check your username and password."
        )
        print("Official error: %s" % ex)
        return {
            "error":
            "access token could not be retrieved. Check your username and password."
        }
Пример #12
0
 def __init__(self):
     self.browser = robobrowser.RoboBrowser()
     self.url = None
     self.response = None
     self.pageinfo = None
     self.content = ''
     self.soup = None
Пример #13
0
def to_api(novel):
    browser = robobrowser.RoboBrowser(history=True,
                                      parser="html.parser",
                                      timeout=60,
                                      tries=5)
    url = 'http://apanr.net/'
    # open anyview a panel
    browser.open(url)
    # login form
    login_form = browser.get_form(id='log-in')
    login_form['account'].value = 'yanghe2008'
    login_form['password'].value = '8443658y'
    browser.submit_form(login_form)
    # access account
    open_account = browser.find(href='/account')
    try:
        browser.follow_link(open_account)
    except:
        print('open anyview website is failed')
        return
    # upload form
    upload_form = browser.get_form()
    # add upload action field
    upload_action_str = '\<input type="hidden" name="action" value="upload_file_post" \/\>'
    upload_action = robobrowser.forms.fields.Input(upload_action_str)
    upload_form.add_field(upload_action)
    # add upload file field
    # path = BASE_DIR + title + ".txt"
    path = os.path.join(BASE_DIR, novel['title'] + ".txt")
    with open(path, 'r', encoding='utf-8') as f:
        upload_form['file_to_upload'].value = f
        browser.submit_form(upload_form)
Пример #14
0
def get_fb_access_token(email, password):
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)
    f = s.get_form()
    s.submit_form(f)
    f = s.get_form()
    f["pass"] = password
    f["email"] = email
    s.submit_form(f)
    f = s.get_form()
    try:
        s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
        access_token = re.search(r"access_token=([\w\d]+)",
                                 s.response.content.decode()).groups()[0]
        return access_token
    except requests.exceptions.InvalidSchema as browserAddress:
        access_token = re.search(r"access_token=([\w\d]+)",
                                 str(browserAddress)).groups()[0]
        return access_token
    except Exception as ex:
        print(
            "access token could not be retrieved. Check your username and password."
        )
        print("Official error: %s" % ex)
        return {
            "error":
            "access token could not be retrieved. Check your username and password."
        }
 def get_data(self):
     robot = robobrowser.RoboBrowser()
     robot.open(self.url_link)
     if robot.response.status_code == 403:
         raise ConnectionError("Forbidden")
     df = self._extract_table(soup=robot.parsed)
     return df
Пример #16
0
 def __init__(self):
     self.browser = robobrowser.RoboBrowser(parser='lxml')
     self.url = None
     self.response = None
     self.pageinfo = None
     self.content = ''
     self.soup = None
     self.url_prefix = 'https://hattiesburg.legistar.com/'
Пример #17
0
def robobrowser_post(target_url):
    print("[robobrowser_post]")
    br = robobrowser.RoboBrowser()
    br.open(target_url)
    form = br.get_form()
    form["q"].value = "谙"
    br.submit_form(form)
    print()
Пример #18
0
def main():
    b = robobrowser.RoboBrowser(parser='lxml')
    b.open('https://github.com/login')
    f = b.get_form(action='/session')
    f['login'].value = '*****@*****.**'
    f['password'].value = 'yourpassword'
    b.submit_form(f)
    for a_tag in b.select('a[href]'):
        print(a_tag.attrs['href'])
Пример #19
0
def download_hare_file():
    browser = robobrowser.RoboBrowser(parser='html5lib')
    browser.open('https://msi.morningstar.com/Login.aspx')
    form = browser.get_forms()[0]
    form.fields['email_addr'].value = '*****@*****.**'
    form.fields['password'].value = MORNINGSTAR_PASSWORD
    browser.submit_form(form)

    browser.open('https://msi.morningstar.com/Export.aspx?type=HarePort')
    return browser.response.text
Пример #20
0
    def __init__(self, username, password, user_agent=None):
        self.username = username
        self.password = password

        self.user_agent = user_agent
        if not self.user_agent:
            self.user_agent = UserAgent.Mobile.iOS.safari

        self.browser = robobrowser.RoboBrowser(user_agent=self.user_agent,
                                               parser="lxml")
Пример #21
0
    def __init__(self, log, scraper=None,
                 browser=None, proxy=None, **kwargs):

        self.log = log
        # BUG Limnoria vs Python requests or cfscrape
        self.scraper = scraper or cfscrape.create_scraper()
        # self.scraper = requests.Session()
        self.browser = browser or robobrowser.RoboBrowser(session=self.scraper, **kwargs)
        self.proxify(proxy)
        self.log.debug("Created SBrowser")
Пример #22
0
def get_politics():

    sense = []
    text = []
    url_ = 'http://www.votenaweb.com.br'
    url_all= ['http://www.votenaweb.com.br/politicos?apenas=Senador&page=1',
           'http://www.votenaweb.com.br/politicos?apenas=Deputado&page=1',
           'http://www.votenaweb.com.br/politicos?apenas=Presidente&page=1'
          ]
    browser = robobrowser.RoboBrowser(history=True, parser='html.parser')
    
    for url in url_all:
    
        browser.open(url)
        politicos = browser.find_all(class_ = 'politician')
    
        for politico in politicos:
            
            link_pol = url_ + str(politico.find('a'))[9:].split('"')[0]
            browser.open(link_pol)
            projects = browser.find_all(class_ = 'bill')
            
            for project in projects:
                
                link_proj = url_ + str(project.find(class_ = 'comments_count'))[32:].split('"')[0]
                browser.open(link_proj)
                comments = browser.find_all(class_ = 'comment comment-depth-0')
                
                for comment in comments:
                    
                    nota_ = comment.find('span')
                    
                    if not nota_:
                        
                        sense.append(0)
                    else:
                        
                        nota = str(nota_).split('<')[1].split('>')[1]
                        mensagem = str(comment.find_all('p')[1]).split('>')[1].split('<')[0]
                        
                        if nota == 'Sim':
                            sense.append(1)
                        
                        if nota == 'Não':
                            sense.append(-1)
                    
                    text.append(mensagem)
    data = []
    
    for i in range(len(text)):
        data.append([text[i], sense[i]])
    data = pd.DataFrame(data, columns = ["Text", "Classificacao"])
    data["Classificacao"] = data["Classificacao"].map({-1: "Negativo", 0: "Neutro", 1: "Positivo",})

    return data
Пример #23
0
 def download(self, book):
     if not os.path.isfile(os.getcwd() + "/books/" + book[1][:-5] + '/' +
                           book[0]):
         base_url = self.base_urls[book[1][:-5]]
         browser = RoboBrowser.RoboBrowser(history=False)
         request = browser.session.get(base_url + book[0], stream=True)
         with open("books/" + book[1][:-5] + '/' + book[0],
                   'wb') as pdf_file:
             pdf_file.write(request.content)
     else:
         print('{} exists already, skipping!'.format(book[0]))
Пример #24
0
    def __init__(self):
        self.br = robobrowser.RoboBrowser(history=True,
                                          parser='html.parser',
                                          user_agent=User_Agent)
        self.br.open('https://fetlife.com/')

        # Set some default values.
        self.country = '14'
        self.state = '160'
        self.location = 'Studio Kink'
        self.address = 'Half way down Caroline lane St Peters 2044 Sydney NSW'
Пример #25
0
def get_prod(product = 'playstation 2'):

    url = 'https://www.mercadolivre.com.br/'
    browser = robobrowser.RoboBrowser(history=True, parser='html.parser')
    browser.open(url)
    form = browser.get_form(action = 'https://www.mercadolivre.com.br/jm/search')
    browser.open(url)
    form['as_word'].value = product
    browser.submit_form(form)
    sense = []
    comments = []
    pags_un = browser.find_all(class_ = 'pagination__page')[2:]
    i = 0
    while i < len(pags_un):
        #print('Página:', i+1)
        item_t1 = browser.find_all('a', class_ = 'item__info-title')
        if len(item_t1) == 0:
            itens = browser.find_all('a', class_ = 'item-link item__js-link')
            t1 = False
        else:
            itens = item_t1
            t1 = True
        for item in itens:
            if t1:
                item_link = str(item)[34:].split('"')[0]
            else:
                item_link = str(item)[41:].split('"')[0]
            browser.open(item_link)
            for com in browser.find_all(class_="review-tooltip expanded"):
                n_stars = len(com.find_all(class_ = "ch-icon-star star-icon star-icon-full"))
                text = str(com.find(class_="review-tooltip-full-body"))[38:].split('<')[0]
                if n_stars > 3:
                    sense.append(1)
                    comments.append(text)
                if n_stars < 3:
                    sense.append(-1)
                    comments.append(text)
                if n_stars == 3:
                    sense.append(0)
                    comments.append(text)
            #print('Produto avaliado')
        browser.open(str(pags_un[i])[39:].split('"')[0])
        i += 1
    x = sense.count(-1)/len(sense)
    #print('Proporção de negativos:', x)
    #print("Total:", len(sense))

    product = product.replace(' ', '_')
    data = []
    for i in range(len(comments)):
        data.append([comments[i], sense[i]])
    data = pd.DataFrame(data, columns = ["Text", "Classificacao"])
    #data.to_csv("data_" + product + ".csv", index = None)
    return data
Пример #26
0
def check_status():
    br = robobrowser.RoboBrowser()
    br.open(url)
    form = br.get_forms()[0]
    string = form.serialize().to_requests()['params'][22][0]
    if string == 'logout':
        return 1
    if string == 'loginotp':
        return 0
    else:
        return -1
Пример #27
0
def get_access_token(email, password):
    s = robobrowser.RoboBrowser(user_agent=MOBILE_USER_AGENT, parser="lxml")
    s.open(FB_AUTH)
    f = s.get_form()
    f["pass"] = password
    f["email"] = email
    s.submit_form(f)
    f = s.get_form()
    s.submit_form(f, submit=f.submit_fields['__CONFIRM__'])
    access_token = re.search(r"access_token=([\w\d]+)", s.response.content.decode()).groups()[0]
    return access_token
Пример #28
0
    def login(self, username: str, password: str) -> None:
        self.br = robobrowser.RoboBrowser(user_agent=self.userAgent)
        self.br.open("https://account.nicovideo.jp/login?site=niconico")

        form = self.br.get_form(id="login_form")
        form["mail_tel"].value = username
        form["password"].value = password
        self.br.submit_form(form)
        self.userId = re.findall("var User = { id: (\d+)",
                                 self.br.state.response.text.replace("\n",
                                                                     ""))[0]
Пример #29
0
def main():
    # 创建浏览器对象
    obj = robobrowser.RoboBrowser(parser='lxml')
    # 通过浏览器加载网页
    obj.open('https://v.taobao.com/v/content/live?catetype=704&from=taonvlang')
    # 获取表单
    form_list = obj.get_form(action='/session')
    # 提交表单
    obj.submit_form(form_list)
    # 筛选带有src属性的img标签
    for img_tag in obj.select('img[src]'):
        print(img_tag.attrs['href'])
Пример #30
0
def main():
    # resp = requests.get('https://github.com/login')
    # 创建浏览器对象
    b = robobrowser.RoboBrowser(parser='lxml')
    b.open('https://github.com/login')
    # 拿到表单
    f = b.get_form(action='/session')
    f['login'].value = 'judong-520'
    f['password'].value = 'ab456654'
    b.submit_form(f)
    for a_tag in b.select('a[href]'):
        print(a_tag.attrs['href'])