You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran the code on Collab, after starting, a notification was sent to my FB account, while on the command promt show that the login approval needed. After I approved the log in, it still run till this error message show up:
_AttributeError Traceback (most recent call last) in <cell line: 26>()
24 # Make sure you provide the correct credentials and the correct login URL
25 # response = scraper.get("https://m.facebook.com/login/") # Use mobile login URL, no need to get this page before login
---> 26 scraper.login(email="***", password="***") # Log in first
27
28 # Now try to access the page after logging in
I ran the code on Collab, after starting, a notification was sent to my FB account, while on the command promt show that the login approval needed. After I approved the log in, it still run till this error message show up:
_AttributeError Traceback (most recent call last)
in <cell line: 26>()
24 # Make sure you provide the correct credentials and the correct login URL
25 # response = scraper.get("https://m.facebook.com/login/") # Use mobile login URL, no need to get this page before login
---> 26 scraper.login(email="***", password="***") # Log in first
27
28 # Now try to access the page after logging in
1 frames
/usr/local/lib/python3.10/dist-packages/facebook_scraper/facebook_scraper.py in submit_form(self, response, extra_data)
949
950 def submit_form(self, response, extra_data={}):
--> 951 action = response.html.find("form", first=True).attrs.get('action')
952 url = utils.urljoin(self.base_url, action)
953 elems = response.html.find("input[name][value]")
AttributeError: 'NoneType' object has no attribute 'attrs'_
This is the code, I've removed my personal infor:
_from facebook_scraper import FacebookScraper, utils, get_group_info
from facebook_scraper.constants import FB_MOBILE_BASE_URL
class FacebookScraper(FacebookScraper):
def get_groups_by_search(self, word: str, **kwargs):
group_search_url = utils.urljoin(FB_MOBILE_BASE_URL, f"search/groups/?q={word}")
r = self.get(group_search_url)
for group_element in r.html.find('div[role="button"]'):
button_id = group_element.attrs["id"]
group_id = find_group_id(button_id, r.text)
yield get_group_info(group_id)
def find_group_id(button_id, raw_html):
s = raw_html[raw_html.rfind(button_id) :]
group_id = s[s.find("result_id:") :].split(",")[0].split(":")[1]
return int(group_id)
scraper = FacebookScraper()
scraper.login(email="", password="") # Log in first
keyword = "Ban Nha"
group_urls = []
for group_info in scraper.get_groups_by_search(keyword): # Now that you're logged in, this should work
group_url = f"https://www.facebook.com/groups/{group_info['id']}"
group_urls.append(group_url)
print(group_urls)_
The text was updated successfully, but these errors were encountered: