Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facebook AutoPost
#1
Hello and much respect to you all Phyton Lovers! I just started learning C langguage and im not so good at Phyton but my question is:
Is it possible to create a program for my News Website?All i need is to automatize all my working and that is: watching a list o website, check for the top viral news, copy 70% of them their text to my website and give credit to site, than post it to my facebook page and groups by multiple accounts. I want you to tell me if it's possible in Phyton or what program i need for this? And one more question...how much cost for a programmer to do that for me? THANKS EVERYONE! Have a great day.
Reply
#2
Selenium is a library for Python with which it is possible to web browser automation.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Quote:And one more question...how much cost for a programmer to do that for me?
IF your offering to pay a programmer instead of learning how to do it yourself, you should of posted in the jobs section. Is this accurate?

Depending on what site it is, you could just use a webscraper such as lxml or BeautifulSoup, etc. But because you have facebook involved, it would most likely be easier in selenium.

Quote:than post it to my facebook page and groups by multiple accounts
what do you mean by multiple accounts?
Recommended Tutorials:
Reply
#4
I really want to learn to do it by myself but i just asked for my curiozity. you say Selenium is the best for this?
Reply
#5
yes, here would be an example of logging into facebook and listing all friends. You can tweak it to do what you want.
change selenium drivers to your paths. More info here.
from selenium import webdriver
import time
import os

URL = 'https://www.facebook.com/'
CHROMEPATH = '/home/metulburr/chromedriver'
PHANTOMPATH = '/home/metulburr/phantomjs'
EMAIL = ''
PASSWORD = ''

class App:
	def __init__(self):
		self.setup_chrome()
		#self.setup_headless()
		self.login()
		self.to_home()
		self.to_friends()
		time.sleep(100000) #keep alive to view html
		
	def delay(self):
		time.sleep(3)
	
	def chrome_prep(self):
		'''get rid of asking to save password and notifications popup'''
		chrome_options = webdriver.ChromeOptions()
		chrome_options.add_experimental_option(
			'prefs', {
				'credentials_enable_service': False,
				"profile.default_content_setting_values.notifications" : 2,
				'profile': {
					'password_manager_enabled': False
				}
			}
		)
		return chrome_options
		
	def setup_chrome(self):
		options = self.chrome_prep()
		os.environ["webdriver.chrome.driver"] = CHROMEPATH
		self.browser = webdriver.Chrome(CHROMEPATH, chrome_options=options)
		self.browser.set_window_position(0,0)
		self.delay()
		
	def setup_headless(self):
		self.browser = webdriver.PhantomJS(PHANTOMPATH)
		self.delay()
		
	def login(self):
		self.browser.get(URL) 
		time.sleep(1) 
		username = self.browser.find_element_by_id("email")
		password = self.browser.find_element_by_id("pass")
		username.send_keys(EMAIL)
		password.send_keys(PASSWORD)
		login_attempt = self.browser.find_element_by_xpath("//*[@type='submit']")
		login_attempt.submit()
		self.delay()
		
	def to_home(self):
		self.browser.execute_script("document.getElementsByClassName('linkWrap noCount')[0].click()")
		self.delay()
	
	def to_friends(self):
		self.browser.execute_script("document.getElementsByClassName('_6-6')[2].click()")
		self.delay()

	def scroll_to_bottom(self):

	    SCROLL_PAUSE_TIME = 0.5
	    # Get scroll height
	    last_height = self.browser.execute_script("return document.body.scrollHeight")

	    while True:
		# Scroll down to bottom
		self.browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")

		# Wait to load page
		time.sleep(SCROLL_PAUSE_TIME)

		# Calculate new scroll height and compare with last scroll height
		new_height = self.browser.execute_script("return document.body.scrollHeight")
		if new_height == last_height:
		    break
		last_height = new_height
		
App()
Recommended Tutorials:
Reply
#6
(Sep-10-2017, 11:55 AM)badpandahere Wrote: Hello and much respect to you all Phyton Lovers! I just started learning C langguage and im not so good at Phyton but my question is:
Is it possible to create a program for my News Website?All i need is to automatize all my working and that is: watching a list o website, check for the top viral news, copy 70% of them their text to my website and give credit to site, than post it to my facebook page and groups by multiple accounts. I want you to tell me if it's possible in Phyton or what program i need for this? And one more question...how much cost for a programmer to do that for me? THANKS EVERYONE! Have a great day.

Phyton is not yet a language, so no, it's not possible.

If you've been learning C, then you've probably learned that computers do not guess at anything, ever.  If you misspell something, the processor doesn't try to figure out what you probably meant to type, instead it just crashes.
Reply
#7
(Sep-11-2017, 05:41 PM)metulburr Wrote: yes, here would be an example of logging into facebook and listing all friends. You can tweak it to do what you want.
change selenium drivers to your paths. More info here.
from selenium import webdriver
import time
import os

URL = 'https://www.facebook.com/'
CHROMEPATH = '/home/metulburr/chromedriver'
PHANTOMPATH = '/home/metulburr/phantomjs'
EMAIL = ''
PASSWORD = ''

class App:
	def __init__(self):
		self.setup_chrome()
		#self.setup_headless()
		self.login()
		self.to_home()
		self.to_friends()
		time.sleep(100000) #keep alive to view html
		
	def delay(self):
		time.sleep(3)
	
	def chrome_prep(self):
		'''get rid of asking to save password and notifications popup'''
		chrome_options = webdriver.ChromeOptions()
		chrome_options.add_experimental_option(
			'prefs', {
				'credentials_enable_service': False,
				"profile.default_content_setting_values.notifications" : 2,
				'profile': {
					'password_manager_enabled': False
				}
			}
		)
		return chrome_options
		
	def setup_chrome(self):
		options = self.chrome_prep()
		os.environ["webdriver.chrome.driver"] = CHROMEPATH
		self.browser = webdriver.Chrome(CHROMEPATH, chrome_options=options)
		self.browser.set_window_position(0,0)
		self.delay()
		
	def setup_headless(self):
		self.browser = webdriver.PhantomJS(PHANTOMPATH)
		self.delay()
		
	def login(self):
		self.browser.get(URL) 
		time.sleep(1) 
		username = self.browser.find_element_by_id("email")
		password = self.browser.find_element_by_id("pass")
		username.send_keys(EMAIL)
		password.send_keys(PASSWORD)
		login_attempt = self.browser.find_element_by_xpath("//*[@type='submit']")
		login_attempt.submit()
		self.delay()
		
	def to_home(self):
		self.browser.execute_script("document.getElementsByClassName('linkWrap noCount')[0].click()")
		self.delay()
	
	def to_friends(self):
		self.browser.execute_script("document.getElementsByClassName('_6-6')[2].click()")
		self.delay()
	def scroll_to_bottom(self.):
	    SCROLL_PAUSE_TIME = 0.5
	    # Get scroll height
	    last_height = self.browser.execute_script("return document.body.scrollHeight")

	    while True:
		# Scroll down to bottom
		self.browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")

		# Wait to load page
		time.sleep(SCROLL_PAUSE_TIME)

		# Calculate new scroll height and compare with last scroll height
		new_height = self.browser.execute_script("return document.body.scrollHeight")
		if new_height == last_height:
		    break
		last_height = new_height
		
App()
Wow, thanks for all the help you gave me, im grateful! <3
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Automating Facebook Posts mieciow 2 1,335 Aug-07-2023, 12:34 PM
Last Post: Gaurav_Kumar
  Web scrapping login facebook credentials kosmas9 0 1,912 Aug-17-2020, 01:33 PM
Last Post: kosmas9
  How to click facebook message button JanelleGuthrie 2 2,372 May-14-2020, 06:02 PM
Last Post: Larz60+
  Application like simpler facebook wall in python framework seidman 1 3,274 Mar-11-2018, 05:07 PM
Last Post: wavic
  Need help with Django 2.0 + Facebook SDK avtrrr 4 4,537 Jan-31-2018, 08:36 AM
Last Post: Larz60+
  facebook friends crawler edithegodfather 12 20,890 Jan-15-2018, 07:07 AM
Last Post: qnkhuat
  I need request POST for Facebook in My Profile Kalet 4 4,246 Sep-27-2017, 05:53 PM
Last Post: Kalet
  facebook scraping metulburr 3 8,249 Jun-02-2017, 01:00 AM
Last Post: metulburr
  Scrape Facebook page user posts text stockholm 6 8,285 May-08-2017, 12:24 PM
Last Post: Joseph_f2

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020