Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Python 3.3 support #3

Closed
Kristinita opened this issue Jan 9, 2018 · 2 comments
Closed

[Feature request] Python 3.3 support #3

Kristinita opened this issue Jan 9, 2018 · 2 comments

Comments

@Kristinita
Copy link

Kristinita commented Jan 9, 2018

1. Request

It would be nice, if Python-GSearch will support Python 3.3.

2. Justification

I write plugin for Sublime Text 3 for scraping first link in Google SERP. Python-GSearch — is only Python module for Google SERP scraping, that works for me in Python 3.6.4 interpreter without bugs. Thank you very much!

But Sublime Text 3 have environment, based on Python 3.3. See reasons, because Sublime Text developers not migrated to 3.6 in these topics:

Plugin developers can't use modules, not compatible with Python 3.3.

3. Settings

For example, I write simple plugin:

import sublime_plugin

from gsearch.googlesearch import search


class GoogleSearchCommand(sublime_plugin.TextCommand):

    def run(self, edit):

        results = search('kristinitaluckylife', num_results=1)
        r = results[0][1]
        print(r)

4. Steps to reproduce

I run GoogleSearchCommand in Sublime Text 3.

5. Expected behavior

As in interpreter:

>>> from gsearch.googlesearch import search
>>> results = search('kristinitaluckylife', num_results=1)
>>> r = results[0][1]
>>> r
'http://www.thepictaram.club/instagram/kristinitaluckylife'
>>> 

6. Actual behavior

Traceback (most recent call last):
  File "C:\Python36\Lib\site-packages\gsearch\googlesearch.py", line 14, in <module>
    from html import unescape
ImportError: cannot import name unescape

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Sublime Text 3 x64\sublime_plugin.py", line 109, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "D:\Sublime Text 3 x64\Data\Packages\TestPlugin\example.py", line 3, in <module>
    from gsearch.googlesearch import search
  File "C:\Python36\Lib\site-packages\gsearch\googlesearch.py", line 23, in <module>
    import urllib2 as request
ImportError: No module named 'urllib2'

I read, that function was introduced in Python 3.4, not in Python 3.3.

Thanks.

@aviaryan
Copy link
Owner

Thank you for the detailed issue, @Kristinita.
This would be definitely nice to have. Here is a way on how to do this.
https://stackoverflow.com/a/2360639/2295672
I would try to solve it sometime. In the meanwhile, if you want to, you can send a PR.

@aviaryan
Copy link
Owner

aviaryan commented Feb 6, 2018

Done!

@aviaryan aviaryan closed this as completed Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants