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

Headless version issue #110

Open
wants to merge 4 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ node_modules/

secret.py
inscrawler/bin/*
!inscrawler/bin/.keep
!inscrawler/bin/.keep
output
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ This crawler could fail due to updates on instagram’s website. If you encounte

## Install
1. Make sure you have Chrome browser installed.
2. Download [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/) and put it into bin folder: `./inscrawler/bin/chromedriver`
3. Install Selenium: `pip3 install -r requirements.txt`
4. `cp inscrawler/secret.py.dist inscrawler/secret.py`
2. Install Selenium: `pip3 install -r requirements.txt`
3. `cp inscrawler/secret.py.dist inscrawler/secret.py`

## User Auth
1. Open `inscrawler/secret.py` file.
Expand Down
Empty file removed inscrawler/bin/.keep
Empty file.
7 changes: 5 additions & 2 deletions inscrawler/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager

from .utils import randmized_sleep


class Browser:
def __init__(self, has_screen):
dir_path = os.path.dirname(os.path.realpath(__file__))
useragent = "Mozilla/5.0 (X11; Linux i686; rv:77.0) Gecko/20100101 Firefox/77.0"

service_args = ["--ignore-ssl-errors=true"]
chrome_options = Options()
chrome_options.add_argument(f'--user-agent={useragent}')
if not has_screen:
chrome_options.add_argument("--headless")
chrome_options.add_argument("--start-maximized")
chrome_options.add_argument("--no-sandbox")
self.driver = webdriver.Chrome(
executable_path="%s/bin/chromedriver" % dir_path,
ChromeDriverManager().install(),
service_args=service_args,
chrome_options=chrome_options,
)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ future==0.16.0
selenium==3.9.0
tqdm==4.23.4
pre-commit==1.16.1
black==19.3b0
black==19.3b0
webdriver-manager==3.2.2