Facebook data scraping with python

Nighcore2

Registered Member
Joined
Apr 30, 2019
Messages
69
Reaction score
4
So i manage to get what i wanted but seems thath they blocked me, now i cannot get what i need, its a string from last post of a public facebook page,

Code:
def Facebook():
    try:
        time.sleep(1)
        proxies = {
            'http': e()
        }
        r = requests.get('https://www.facebook.com/example/', verify=True,proxies=proxies)
        print(r.text)
        words = re.findall('String (.{24})', r.text)
        z = words[0]
        x = re.split('\s+', z)
    except IndexError:
        print("Something failed in facebook call, request cannot find / blocked")
        pass

So any idea for scrape? i just need to get publication text content from public facebook page, paying isnt a problem depending on price but i need to get each second/2seconds do the request for get them.
 
Maybe update headers, with current headers you look like a bot :)
Also proxies should be:
Code:
{
"http":proxy,
"https":proxy
}
Right now your script dont use proxies for fb because fb url is https and you tell python to use proxy only for http, not for https.
 
Maybe update headers, with current headers you look like a bot :)
Also proxies should be:
Code:
{
"http":proxy,
"https":proxy
}
Right now your script dont use proxies for fb because fb url is https and you tell python to use proxy only for http, not for https.

what headers i should use? sniff packets from phone maybe and use them as header?
also getting cookies can be usefull with a GET and then use thath cookies in post? or thath has nothing to do for look more real?
any other advice(thanks btw)
 
Headers:
https://pypi.org/project/fake-headers/

Cookies wont help since in your code there are no post requests, are you going to perform any post requests?

When it comes to cookies:
Code:
s = requests.session()
s.proxies.update(proxies)
s.get('https://www.facebook.com')
s.post('https://www.facebook.com')
print(s.cookies())
In this way you dont have to deal with cookies that much. All cookies will be updated when you do requests etc.

In theory packet sniffing is not that bad idea if you want to do this better and in more threads. Install mitm proxy on your PC and check packets in firefox browser ;)
 
15 private proxys, 1 request every second in last hour with fake headers(i edited for just use accept encoding deflated, no gzip or br because sometimes i was getting request text encoded in a non redeable form) 0 bans, seems i already manage to do what i needed
 
Back
Top