Posts: 3
Threads: 1
Joined: Sep 2017
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.
Posts: 2,953
Threads: 48
Joined: Sep 2016
Selenium is a library for Python with which it is possible to web browser automation.
Posts: 5,151
Threads: 396
Joined: Sep 2016
Sep-10-2017, 10:30 PM
(This post was last modified: Sep-10-2017, 10:30 PM by metulburr.)
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:
Posts: 3
Threads: 1
Joined: Sep 2017
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?
Posts: 5,151
Threads: 396
Joined: Sep 2016
Sep-11-2017, 05:41 PM
(This post was last modified: Sep-12-2017, 11:26 AM by metulburr.)
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:
Posts: 3,458
Threads: 101
Joined: Sep 2016
(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.
Posts: 3
Threads: 1
Joined: Sep 2017
(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
|