Google Command Line Script.rar

  • Volha
    了解作者
  • Python
    开发工具
  • 12KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-02-15 21:20
    上传日期
Command line for Google services
Google Command Line Script.rar
  • Google Command Line Script.docx
    14.5KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/6267af2c4f8811599ef11d82/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/6267af2c4f8811599ef11d82/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">Google Command Line Scrip<span class="_ _0"></span>t</div><div class="t m0 x1 h4 y3 ff1 fs1 fc0 sc0 ls0 ws0">To make it a bit interactive, we will ask the user for an inpu<span class="_ _1"></span>t and save the result to a</div><div class="t m0 x1 h4 y4 ff1 fs1 fc0 sc0 ls0 ws0">variable that we name &#8220;query&#8221;<span class="_ _1"></span>.</div><div class="t m0 x1 h5 y5 ff2 fs1 fc0 sc0 ls0 ws0">query = raw_input("What do you want to search for ? &gt;&gt; ")</div><div class="t m0 x1 h4 y6 ff1 fs1 fc0 sc0 ls0 ws0">Create the response object by loading the the URL re<span class="_ _1"></span>sponse, including the query </div><div class="t m0 x1 h4 y7 ff1 fs1 fc0 sc0 ls0 ws0">we asked for above.</div><div class="t m0 x1 h5 y8 ff2 fs1 fc0 sc0 ls0 ws0">response = urllib2.urlopen (url + query ).read()</div><div class="t m0 x1 h4 y9 ff1 fs1 fc0 sc0 ls0 ws0"># Process the JSON string. da<span class="_ _1"></span>ta = json.loads (response)</div><div class="t m0 x1 h4 ya ff1 fs1 fc0 sc0 ls0 ws0">From this point we can play around with th<span class="_ _1"></span>e results</div><div class="t m0 x1 h6 yb ff3 fs1 fc0 sc0 ls0 ws0">GoogleSearch.py</div><div class="t m0 x1 h4 yc ff1 fs1 fc0 sc0 ls0 ws0">Let&#8217;s see the complete script</div><div class="t m0 x1 h5 yd ff2 fs1 fc0 sc0 ls0 ws0">import urllib2</div><div class="t m0 x1 h5 ye ff2 fs1 fc0 sc0 ls0 ws0">import urllib</div><div class="t m0 x1 h5 yf ff2 fs1 fc0 sc0 ls0 ws0">import json</div><div class="t m0 x1 h5 y10 ff2 fs1 fc0 sc0 ls0 ws0">url = </div><div class="t m0 x1 h5 y11 ff2 fs1 fc0 sc0 ls0 ws0">"http://ajax.googleapis.com/ajax/services/search/web?</div><div class="t m0 x1 h5 y12 ff2 fs1 fc0 sc0 ls0 ws0">v=1.0&amp;"</div><div class="t m0 x1 h5 y13 ff2 fs1 fc0 sc0 ls0 ws0">query = raw_input("What do you want to search for ? &gt;&gt; ")</div><div class="t m0 x1 h5 y14 ff2 fs1 fc0 sc0 ls0 ws0">query = urllib.urlencode( {'q' : query } )</div><div class="t m0 x1 h5 y15 ff2 fs1 fc0 sc0 ls0 ws0">response = urllib2.urlopen (url + query ).read()</div><div class="t m0 x1 h5 y16 ff2 fs1 fc0 sc0 ls0 ws0">data = json.loads ( response )</div><div class="t m0 x1 h5 y17 ff2 fs1 fc0 sc0 ls0 ws0">results = data [ 'responseData' ] [ 'results' ]</div><div class="t m0 x1 h5 y18 ff2 fs1 fc0 sc0 ls0 ws0">for result in results:</div><div class="t m0 x1 h5 y19 ff2 fs1 fc0 sc0 ls0 ws0"> title = result['title']</div><div class="t m0 x1 h5 y1a ff2 fs1 fc0 sc0 ls0 ws0"> url = result['url']</div><div class="t m0 x1 h5 y1b ff2 fs1 fc0 sc0 ls0 ws0"> print ( title + '; ' + url )</div><div class="t m0 x1 h4 y1c ff1 fs1 fc0 sc0 ls0 ws0">Open an text editor , copy &amp; paste the code above.</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • Git-CommandLine
      Git-CommandLine
    • Command Line Assistant-开源
      命令行助手是一个图形用户界面GUI,旨在帮助使用命令行界面CLI。 它是一个Java应用程序,可构建要在CLI提示符下使用的命令。
    • CommandLine-开源
      这是一个 .net 库,可帮助扫描命令行并以直接和面向对象的方式读取参数和参数,而不是访问字符串数组
    • git-commandline
      该存储库是专门为学习和记住GIT命令行而创建的 从各种来源学习GIT命令。 这对于希望从头开始学习GIT命令行的任何人都是有帮助的。 在本资料库中,我将介绍最常用的GIT命令,而不介绍最先进的GIT命令。
    • Woof.CommandLine
      Woof.CommandLine 由创建的.NET扩展 根据。 (c)2021由CodeDog Ltd.保留所有权利。 关于 快速命令行解析器。 将命令行参数解析为参数和选项。 选项是一个以前缀开头的参数。 参数是不可选项的参数。 可以通过它们...
    • cache from command line
      NULL 博文链接:https://schi.iteye.com/blog/843083
    • CommandLineTools-master.zip
      CommandLineTools Library for Delphi.zip
    • commandline args test.zip
      Command line arguments test
    • 软件开发计划书 .asp.rar
      一个完整的项目开发文档,可以看看.没有坏处.