0

More Generally: How can I run a process that runs from the terminal with required keyword arguments using python?

It seems subprocess.Popen is what I want to use.

Here is what I try to run from inside a script:

from subprocess import Popen
Popen(['goodreads-user-scraper', '--user_id 149832357'])

“goodreads-user-scraper” is recognized, but I don’t understand how to pass a keyword argument. I know how to pass an argument, but if I remove “—user_id” I still get same problem. enter image description here

I have installed goodreads-user-scraper. It works well from the terminal. It is a python package that you can run from the terminal. Repository found here.

Below is how I would ideally like to run the process but from inside python:

pip install goodreads-user-scraper
goodreads-user-scraper --user_id <your id> --output_dir goodreads-data

Result of running from terminal: enter image description here

Research

In my research I have found these two that seem helpful, but I haven’t been able to adapt the answers to my needs:
costa rica
  • 85
  • 1
  • 12

1 Answers1

0

Separate all of your arguments like this:

from subprocess import Popen
Popen(['goodreads-user-scraper', '--user_id', '149832357'])
jprebys
  • 2,469
  • 1
  • 11
  • 16