Code Monkey home page Code Monkey logo

Comments (5)

paladini avatar paladini commented on July 4, 2024 5

If anyone is having the same issue, I've found how to fix that! Just change the following code from the comments scraper:

def request_until_succeed(url):
    req = Request(url)
    success = False
    while success is False:
        try:
            response = urlopen(req)
            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 response.read()

To this one (i've added .decode('utf-8') before returning the value):

    req = Request(url)
    success = False
    while success is False:
        try:
            response = urlopen(req)
            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 response.read().decode('utf-8')

Now it's working fine here, but don't know if it's reliable for everyone, so I'm not going to submit a pull request with this fix.

from facebook-page-post-scraper.

minimaxir avatar minimaxir commented on July 4, 2024

The script does encoding/decoding shenanigans in order to be compatible with both Python 2 and 3. I will have to check if that solution will work for Python 2.

from facebook-page-post-scraper.

paladini avatar paladini commented on July 4, 2024

Thanks for the fast reply, @minimaxir !

from facebook-page-post-scraper.

Mika15 avatar Mika15 commented on July 4, 2024

Guys, again I have an issue with paging. Cannot figure out why it is happening. Can you help me? Thanks!
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
176
177 if name == 'main':
--> 178 scrapeFacebookPageFeedStatus(group_id, access_token)

in scrapeFacebookPageFeedStatus(group_id, access_token)
160 if 'paging' in statuses:
161 next_url = statuses['paging']['next']
--> 162 until = re.search('until=([0-9]*?)(&|$)', next_url).group(1)
163 if until is None:
164 return None

AttributeError: 'NoneType' object has no attribute 'group'`

from facebook-page-post-scraper.

nxy avatar nxy commented on July 4, 2024

@paladini thanks worked for me

from facebook-page-post-scraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.