facebook-page-post-scraper icon indicating copy to clipboard operation
facebook-page-post-scraper copied to clipboard

until date issue

Open iamrajeshchauhan opened this issue 8 years ago • 9 comments
trafficstars

Hello Minimaxir,

In python code line no. 187 showing some error while running with since and until date.

code : if 'paging' in statuses: next_url = statuses['paging']['next'] until = re.search('until=([0-9]?)(&|$)', next_url).group(1) paging = re.search( '__paging_token=(.?)(&|$)', next_url).group(1)

error :

Traceback (most recent call last): File "Fbpost.py", line 199, in scrapeFacebookPageFeedStatus(group_id, access_token, since_date, until_date) File "Fbpost.py", line 187, in scrapeFacebookPageFeedStatus until = re.search('until=([0-9]*?)(&|$)', next_url).group(1) AttributeError: 'NoneType' object has no attribute 'group'

can anybody help me what is the issue while running this new Facebook page python code

Thanks

iamrajeshchauhan avatar Jun 20 '17 08:06 iamrajeshchauhan

@iamrajeshchauhan What is happening is that the re.search command in line 187, i.e.

until = re.search('until=([0-9]?)(&|$)', next_url).group(1)

is returning no results.

And since there are no results produced, the return type of the re.search() command will be NoneType and NoneType has no attribute called group in it.

Hope it helps! :)

gabru-md avatar Jun 20 '17 09:06 gabru-md

@gabru-md So while running code what should I do?

iamrajeshchauhan avatar Jun 20 '17 09:06 iamrajeshchauhan

what page are you trying to scrape?

gabru-md avatar Jun 20 '17 10:06 gabru-md

it's not fixed, so in the code what changes are we require to solve the error. You can take any page example for scrapping.

iamrajeshchauhan avatar Jun 20 '17 10:06 iamrajeshchauhan

Huh, I tested this workflow and didn't see an error. A possible cause is that if there isn't a next_url.

A workaround may be to only set until if no defined until exists.

minimaxir avatar Jun 20 '17 16:06 minimaxir

great ! thanks, @minimaxir Is that possible can we scrap the data(comments, reply, likes, etc) from Facebook where the post was live video?

iamrajeshchauhan avatar Jun 21 '17 06:06 iamrajeshchauhan

@minimaxir Hi, I am getting the same error. I gave since_date = "2017-01-01" # ( 1st Jan 2017 ) until_date = "2017-07-02" # ( 2nd July 2017) . The error comes just after 100 records (1st July 2017 back to 8th Feb 2017) are written on the .cv file. Post are available in the page for Jan 2017 also.

LinuxBeginner avatar Jul 02 '17 12:07 LinuxBeginner

Hi @minimaxir I am experiencing the same issue. I only get the first 100 records. Thereafter I get the same error. I know there are many more. I tried different dates, always get 100 records only. I am not sure how to implement your suggestion from June 20th, above. Any suggestions, please?

tiborko avatar Sep 07 '17 01:09 tiborko

Hi @tiborko ,

I think if you can use below script for scrapping that would be great.

https://github.com/minimaxir/facebook-page-post-scraper/blob/master/get_fb_posts_fb_page.py

Thanks !

iamrajeshchauhan avatar Sep 07 '17 06:09 iamrajeshchauhan