Skip to content

Instantly share code, notes, and snippets.

@bobquest33
Created October 18, 2018 03:57
Show Gist options
  • Save bobquest33/4b8a4a11ec87bc0d4d3d47c4aa929223 to your computer and use it in GitHub Desktop.
Save bobquest33/4b8a4a11ec87bc0d4d3d47c4aa929223 to your computer and use it in GitHub Desktop.
Shows how to do Google Search with Python search library
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[('investFeed [$IFT] ICO Official Thread-Cryptocurrency Incentivized ...', 'https://bitcointalk.org/index.php?topic=1989821.0'), ('[ANN] investFeed [$IFT] - Official Beta 1.0 - Launch Thread ...', 'https://bitcointalk.org/index.php?topic=4951455.0'), ('[ANN] investFeed [$IFT] - Official Beta 1.0 - Launch Thread ...', 'https://bitcointalk.org/index.php?topic=4951455.20'), ('[ANN] investFeed [$IFT] - Official Beta 1.0 - Launch Thread ...', 'https://bitcointalk.org/index.php?topic=4951455.40'), ('[ANN][ICO][BOUNTY] InvestFeed Kripto Para Teşvikli Sosyal Paylaşım ...', 'https://bitcointalk.org/index.php?topic=2040810.0'), ('[Bounty] InvestFeed #1 Cryptocurrency Incentivized Social Network ...', 'https://bitcointalk.org/index.php?topic=2027432.0'), ('investFeed [$IFT] ICO Official Thread-Cryptocurrency Incentivized ...', 'https://bitcointalk.org/index.php?topic=1989821.260'), (' [ANN] ICObazaar - Crypto Market Insight - Bitcoin Forum', 'https://bitcointalk.org/index.php?topic=1944524.60'), ('[ANN] Real Estate Blockchain Crowdfunding Technology - Bitcointalk', 'https://bitcointalk.org/index.php?topic=2064991.0'), ('investFeed [$IFT] ICO Official Thread-Cryptocurrency Incentivized ...', 'https://bitcointalk.org/index.php?topic=1989821.960')]\n"
]
}
],
"source": [
"from gsearch.googlesearch import search\n",
"query = \"bitcointalk.org investfeed ann\"\n",
"lang = \"en\"\n",
"num = 5\n",
"results = search(query=query) \t# This is for normal search\n",
"print(results)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://bitcointalk.org/index.php?topic=1989821.0\n"
]
}
],
"source": [
"from urllib.parse import unquote\n",
"url = unquote(results[0][1])\n",
"print(url)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://ip.bitcointalk.org/?u=http://i.imgur.com/1wvzTZf.png&t=579&c=XRXdJHoT5ni7fQ\n"
]
}
],
"source": [
"print(unquote(\"https://ip.bitcointalk.org/?u=http%3A%2F%2Fi.imgur.com%2F1wvzTZf.png&t=579&c=XRXdJHoT5ni7fQ\"))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment