Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed firefox_profile and some xpath and css selectors. #6718

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions instapy/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from selenium.webdriver.firefox.options import Options as Firefox_Options
from selenium.webdriver import Remote
from webdriverdownloader import GeckoDriverDownloader
from selenium.webdriver.firefox.service import Service as FirefoxService

# import InstaPy modules
from .util import interruption_handler
Expand Down Expand Up @@ -112,18 +113,18 @@ def set_selenium_local_session(
# prevent Hide Selenium Extension: error
firefox_profile.set_preference("dom.webdriver.enabled", False)
firefox_profile.set_preference("useAutomationExtension", False)
firefox_profile.set_preference("general.platform.override", "iPhone")
firefox_profile.update_preferences()

firefox_profile.set_preference("general.platform.override", "iPhone")
firefox_options.profile = firefox_profile
# geckodriver log in specific user logfolder
geckodriver_log = "{}geckodriver.log".format(logfolder)

# prefer user path before downloaded one
driver_path = geckodriver_path or get_geckodriver()
ser = FirefoxService(executable_path=driver_path, log_path=geckodriver_log)
browser = webdriver.Firefox(
firefox_profile=firefox_profile,
executable_path=driver_path,
log_path=geckodriver_log,
# firefox_profile=firefox_profile,
service=ser,
options=firefox_options,
)

Expand Down
23 changes: 13 additions & 10 deletions instapy/xpath_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,21 @@
xpath["get_links_from_feed"] = {"get_links": "//*[contains(@class,'c-Yi7')]"}

xpath["get_links_for_tag"] = {
"top_elements": "//main/article/div[1]/div[1]/div[1]",
"main_elem": "//main/article/div[1]/div[1]/div[1]/div[1]",
"possible_post": "//div[contains(@class, '_aabd _aa8k _aanf')]",
"top_elements": "//main/article/div[1]",
"main_elem": "//main/article/div[2]",
"possible_post": "//span[contains(@class, 'g47SY')]",
}


xpath["get_number_of_posts"] = {
"num_of_posts_txt": "//section/main/div/ul/li[1]/span/span",
"num_of_posts_txt_no_such_element": "//section/div[3]/div/header/section/ul/li[1]/span/span",
}

xpath["get_relationship_counts"] = {
"following_count": "//a[contains(@href,'following') and not(contains(@href,'mutual'))]//span",
"followers_count": "//a[contains(@href,'followers') and not(contains(@href,'mutual'))]//span",
# "following_count": "//a[contains(@href,'following') and not(contains(@href,'mutual'))]/span/span",
"following_count": "//a[contains(@href,'following') and not(contains(@href,'mutual'))]/span/span/span",
# "followers_count": "//a[contains(@href,'followers') and not(contains(@href,'mutual'))]/span",
"followers_count": "//a[contains(@href,'followers') and not(contains(@href,'mutual'))]/span/span", # get title attritbute
"topCount_elements": "//span[contains(@class,'g47SY')]",
}

Expand All @@ -160,8 +161,10 @@
}

xpath["like_image"] = {
"like": "//*[contains(@class, '_aamw')]/button/div/*[*[local-name()='svg']/@aria-label='Like']/*",
"unlike": "//*[contains(@class, '_aamw')]/button/div/*[*[local-name()='svg']/@aria-label='Unlike']/*",
# "like": "//*[contains(@class, 'fr66n')]/button/div/*[*[local-name()='svg']/@aria-label='Like']/*",
"like": "[class='xp7jhwk']>button",
# "unlike": "//*[contains(@class, 'fr66n')]/button/div/*[*[local-name()='svg']/@aria-label='Unlike']/*",
"unlike": "[class='x78zum5']>span:nth-child(2)>button",
"play": "//*/span[contains(@aria-label, 'Play')]",
}

Expand All @@ -172,9 +175,9 @@
xpath["login_user"] = {
"input_password": "//input[@name='password']",
"input_username_XP": "//input[@name='username']",
"login_elem": "//button[text()='Log In']",
"login_elem": "//div[text()='Log in']",
"login_elem_no_such_exception": "//a[text()='Log in']",
"login_elem_no_such_exception_2": "//div[text()='Log In']",
"login_elem_no_such_exception_2": "[type='submit']",
"nav": "//nav",
"website_status": "//span[@id='status']",
"response_time": "//span[@id='response']",
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
api-display-purposes>=0.0.3; python_version > '3.5'
certifi>=2018.10.15
chardet>=3.0.4,<4
clarifai>=2.4.1
clarifai==2.6.2
configparser>=3.5.0,<4
EasyProcess>=0.2.3
emoji>=1.6.0
emoji==1.7
future>=0.17.1
grpcio>=1.16.1
idna>=2.7,<3
Expand All @@ -21,4 +21,4 @@ selenium>=3.141.0
setuptools_rust>=0.11.6
six>=1.11.0
urllib3>=1.24.1
webdriverdownloader>=1.1.0.3
webdriverdownloader>=1.1.0.3