Code Monkey home page Code Monkey logo

quora-expander's Introduction

Quora-expander

quora-expander is a command-line application written in Python that can automatically expand collapsed answers and comments for any given Quora user.

To run quora-expander:

  1. Download quora-expander.py to your local machine, either manually or using git clone
  2. Set up python (>= v3.9.1) to be run inside a terminal on your local machine
  3. Make sure you have Google Chrome installed on your local machine
  4. Download a version of chromedriver that is compatible with your machine and the installed version of Google Chrome and put the chromedriver binary inside the same directory as the quora-expander.py script, possibly replacing any one that was there before.
  5. If you don't need the comments, run the quora-expander as shown below without the -m argument.
  6. However, to get the full benefits of this script, including the expansion of all the comments, you'll need to log into quora first. For this, use the command in combination with the -m argument (see further below). This will open the profile page you want to expand. Then, remaining on this page, log into quora. After logging in, make sure you are still on the same profile page (but now logged into quora) and only now run the do_all() command multiple times until everything is expanded.

Without the -m argument

$ python -i quora-expander.py [profile_id]

e.g.

$ python -i quora-expander.py Artem-Boytsov

Once the script has finished with the automatic execution of commands, it will drop into interactive mode and let you run any or all of the individual commands manually, to make sure nothing was missed.

Optinally, when you first run the script, you can pass the additional argument -m or --manual to skip the automatic execution of commands and drop immediately into the interactive shell, letting you pick and choose from the processing commands.

$ python -i quora-expander.py [profile_id] -m

Once you are in the interactive shell, you can type do_ and the Tab key (twice) to get the list of commands at your disposal:

>>> do_
do_all(                        
do_expand_hidden_comments(     
do_print_manual_instructions(  
do_scrolldown(                 
do_show_more(
do_show_more_of_answers(       
do_show_more_of_comments(
do_try_again(
do_view_collapsed_comments(
do_view_more_comments(
do_view_more_replies(

Finish typing the command you want, close the parenthesis, and hit Enter.

E.g. the following command:

>>> do_view_more_comments()

will click on all "View more comments" buttons it can find on the page, and once it has finished, will start over again until there are either no more "View more comments" buttons on the page or until it determines that the number of buttons on the page isn't changing after clicking on all of them.

It will print out how many instances of that button it has found on the page each time it checks:

clicking on 141 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 28 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 11 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 7 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 4 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 4 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 3 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 1 instances of "//div[text()[contains(., 'View more comments')]]"
clicking on 0 instances of "//div[text()[contains(., 'View more comments')]]"
>>> 

Whereas this command:

>>> do_all()

will call each of the individual commands once, in the appropriate order.

Finally,

>>> do_print_manual_instructions()

will print a brief instruction message mentioning how to use the other commands.

To exit:

  • you can either type exit() followed by the Enter key to exit the interactive shell, but leave the browser open, or
  • you can press Ctrl-D to exit the shell and close the browser all at the same time.

From time to time, Quora might change the stucture of their html/css code and the xpath/css selectors will stop working. If you get the impression that running the commands is not clicking on any of the links they are supposed to, check the individual xpath and css selectors in the code and adapt them to make them successfully select the links you want quora-expander to click on for you.


This project uses the following license: MIT

quora-expander's People

Contributors

swiss-chris avatar banyous avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.