Jump to content
sharkyz

Find direct links on google (script)

Recommended Posts

Posted (edited)

Am avut nevoie sa gasesc repede link-uri directe la aproape 50 de carti dupa amazon asa ca am scris 10 linii de cod si gata.

 

Requirements:

    Python 2.7

    pip install google

 

googlesearch.py

from google import search
from time   import sleep
import sys

def direct_search(title, ext, multi='off'):
    print title
    sleep(2)
    for url in search(title + ' ' + ext, stop=10):
        if (url.endswith('.pdf')):
            print url
            if (multi == 'off'):
                break

if __name__ == "__main__":
    if (len(sys.argv) < 4):
        print 'usage: ./%s file.txt format multi=\'on/off\'' % sys.argv[0]
        print 'ex. :  ./%s book-titles.txt pdf off' % sys.argv[0]
    else:
        with open(sys.argv[1], 'r') as file:
            for line in file:
                line = line.rstrip()
                links = direct_search(line, sys.argv[2], sys.argv[3])
                if not line: continue
        file.close()

Se foloseste in urmatorul fel:

Creati un fisier si puneti in el numele de la carti listate unu sub celalt in urmatorul fel:

 

fisier.txt

 

Test-Driven Development with Python
Fluent Python 1st Edition
Foundations of Python Network Programming 3rd edition
Python Network Programming Cookbook

Si apoi rulati applicatia cu:

./googlesearch.py fisier.txt mp4 off

daca vreti sa salvati linkurile intrun fisier:

./googlesearch.py fisier.txt mp4 off > urls.txt

 

 

In caz ca nu va da rezultate incercati sa schimbati stop cu o valuare mai mare de 40.

Edited by sharkyz
  • Upvote 6

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...