Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Error in line 184 and 154 #101

Open
mparackal opened this issue Mar 11, 2018 · 4 comments
Open

Error in line 184 and 154 #101

mparackal opened this issue Mar 11, 2018 · 4 comments

Comments

@mparackal
Copy link

I am not a programmer but can find my way through codes like a blind man. So, can you help me, please? I get the following error, not sure what I am doing wrong. Also, the current Facebook API version is 2.12. This code is point to version 2.9 (base = "https://graph.facebook.com/v2.9" # line 139).

Thank you & Kind regard

Mathew

Traceback (most recent call last):
File "C:\Users\parma73p\Desktop\Python\get_fb_posts_fb_page.py", line 184, in
scrapeFacebookPageFeedStatus(page_id, access_token, since_date, until_date)
File "C:\Users\parma73p\Desktop\Python\get_fb_posts_fb_page.py", line 154, in scrapeFacebookPageFeedStatus
statuses = json.loads(request_until_succeed(url))
File "C:\Program Files\IBM\SPSS\Statistics\24\Python3\lib\json_init_.py", line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not 'bytes'

@semmet95
Copy link

Hey there.
Can you share the URL you're trying to scrape data from?

@mparackal
Copy link
Author

thanks singh-95.

The URL is https://www.facebook.com/NZMSCAlpine/

@semmet95
Copy link

@mparackal the script is successfully scraping data from the page you shared when I test it. Can you please share your code?

@trevdog94
Copy link

trevdog94 commented Jun 22, 2018

I altered the request_until_succeed to look like this and it resolved the issue for me:

def request_until_succeed(url):
    req = Request(url)
    success = False
    while success is False:
        try:
            response = urlopen(req)
            **res = response.read()
            res = res.decode("utf-8")**
            if response.getcode() == 200:
                success = True
        except Exception as e:
            print(e)
            time.sleep(5)

            print("Error for URL {}: {}".format(url, datetime.datetime.now()))
            print("Retrying.")

    return res

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants