■ ■ ■ ■ ■ ■
modules/search/instagram.py
| skipped 19 lines |
20 | 20 | | meta = { |
21 | 21 | | 'name': 'Instagram Search', |
22 | 22 | | 'author': 'Aman Singh', |
23 | | - | 'version': '0.5', |
| 23 | + | 'version': '0.7', |
24 | 24 | | 'description': 'Search your query in the Instagram and show the results.', |
25 | 25 | | 'sources': ('google', 'carrot2', 'bing', 'yippy', 'yahoo', 'millionshort', 'qwant', 'duckduckgo', 'instagram'), |
26 | 26 | | 'options': ( |
27 | 27 | | ('query', None, True, 'Query string', '-q', 'store', str), |
28 | 28 | | ('limit', 1, False, 'Search limit(number of pages, default=1)', '-l', 'store', int), |
29 | 29 | | ('count', 50, False, 'Number of links per page(min=10, max=100, default=50)', '-c', 'store', int), |
30 | | - | ('engine', 'google,instagram', False, 'Engine names for search(default=google, instagram)', '-e', 'store', str), |
| 30 | + | ('engine', 'google', False, 'Engine names for search(default=google, instagram)', '-e', 'store', str), |
31 | 31 | | ('session_id', None, False, 'Insta Account Session_id for more details results (default="")', '-s', 'store', str), |
32 | 32 | | ('thread', 2, False, 'The number of engine that run per round(default=2)', '-t', 'store', int), |
33 | 33 | | ), |
| skipped 7 lines |
41 | 41 | | FOLLOWING = [] |
42 | 42 | | POST = [] |
43 | 43 | | |
44 | | - | def search(self, name, q, q_formats, limit, count,session_id): |
| 44 | + | def search(self, name, q, q_formats, limit, count, session_id): |
45 | 45 | | global PAGES,LINKS,USERDATA,FOLLOWERS,FOLLOWING,POST |
46 | 46 | | eng = name |
47 | 47 | | query = q |
| skipped 10 lines |
58 | 58 | | FOLLOWERS = attr.followers |
59 | 59 | | FOLLOWING = attr.following |
60 | 60 | | POST = attr.post |
61 | | - | |
| 61 | + | USERDATA = attr.userdata |
62 | 62 | | # for others |
63 | 63 | | else : |
64 | 64 | | if 'limit' in varnames and 'count' in varnames: |
| skipped 6 lines |
71 | 71 | | attr.run_crawl() |
72 | 72 | | LINKS += attr.links |
73 | 73 | | PAGES += attr.pages |
74 | | - | USERDATA = attr.userdata |
75 | 74 | | |
76 | 75 | | def module_api(self): |
77 | 76 | | query = self.options['query'] |
| skipped 2 lines |
80 | 79 | | session_id = self.options['session_id'] or '' |
81 | 80 | | engine = self.options['engine'].split(',') |
82 | 81 | | output = { |
83 | | - | 'error': None, |
84 | 82 | | 'people': [], |
85 | 83 | | 'posts': [], |
86 | 84 | | 'hashtags': [], |
| skipped 7 lines |
94 | 92 | | return |
95 | 93 | | |
96 | 94 | | q_formats = { |
97 | | - | 'google_q': f"site:www.instagram.com inurl:{query}", |
98 | 95 | | 'default_q': f"site:www.instagram.com {query}", |
| 96 | + | 'google_q': f"site:www.instagram.com inurl:{query}", |
99 | 97 | | 'yippy_q': f"www.instagram.com {query}", |
100 | 98 | | 'instagram': f"{query}" |
101 | 99 | | } |
| skipped 30 lines |
132 | 130 | | output['posts'].extend(POST) |
133 | 131 | | output['followers'] = FOLLOWERS |
134 | 132 | | output['following']= FOLLOWING |
| 133 | + | output['links'] = links |
135 | 134 | | |
136 | 135 | | output = {key: val for key, val in output.items() if val} |
137 | 136 | | |
| skipped 6 lines |