sensiblecodeio / scraperwiki-python

ScraperWiki Python library for scraping and saving data
https://scraperwiki.com
BSD 2-Clause "Simplified" License
160 stars 69 forks source link

Module has no attribute scrape #44

Closed mattdbr closed 10 years ago

mattdbr commented 10 years ago

It might just be because I'm an amateur but when I run my code I get this error. Here's my code

import scraperwiki
fixtuers = scraperwiki.scrape('http://www.sydgram.nsw.edu.au/co-curricular/sport/fixtures/2013-06-01.php')
print(fixtures)
pwaller commented 10 years ago

I can't reproduce that here from within a scraperwiki dataset. Could you please tell us more about your environment?

Could you also do print(dir(scraperwiki))?

In [5]: dir(scraperwiki)
Out[5]: 
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 'pdftoxml',
 'scrape',
 'sql',
 'sqlite',
 'status',
 'utils']
pwaller commented 10 years ago

Thanks for reporting!

I'm closing this since I can't reproduce the error from what you've posted so far. If you post the full error output and let me know where you're running it (on our platform? on your laptop? Python version? etc), then I'll reopen it.

Another good place to ask for help with this sort of thing, with a wider audience, might be our google group.

mattdbr commented 10 years ago
F:\Desktop>python scraperwiki.py
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__spec__', 'scraperwiki']
Traceback (most recent call last):
  File "scraperwiki.py", line 1, in <module>
    import scraperwiki
  File "F:\Desktop\scraperwiki.py", line 3, in <module>
    scraperwiki.scrape('http://www.sydgram.nsw.edu.au/co-curricular/sport/fixtur
es/2013-06-01.php')
AttributeError: 'module' object has no attribute 'scrape'

Here's the output with print(dir(scraperwiki))

pwaller commented 10 years ago

It looks a bit like you haven't installed scraperwiki-python with a python package manager. How did you install it? Have you installed it using pip scraperwiki?

mattdbr commented 10 years ago

This is running on my desktop Python 3.4 Windows 8.1

mattdbr commented 10 years ago
C:\Users\Matt>pip install scraperwiki
Requirement already satisfied (use --upgrade to upgrade): scraperwiki in c:\pyth
on34\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): dumptruck>=0.1.2 in c:
\python34\lib\site-packages (from scraperwiki)
Requirement already satisfied (use --upgrade to upgrade): requests in c:\python3
4\lib\site-packages (from scraperwiki)
Cleaning up...

I just checked and apparently scraperwiki is installed with pip

pwaller commented 10 years ago

Ah, you've called your module scraperwiki.py, so import scraperwiki is picking up your module, not scraperwiki-python. Can you rename your module to something else and try again?

mattdbr commented 10 years ago

Well that seems to fix half the problems. Now it's insisting that I use urllib2 which isn't present


F:\Desktop>python sgsold.py
Traceback (most recent call last):
  File "sgsold.py", line 1, in <module>
    import scraperwiki
  File "C:\PYTHON34\lib\site-packages\scraperwiki\__init__.py", line 9, in <modu
le>
    from .utils import scrape, pdftoxml, status
  File "C:\PYTHON34\lib\site-packages\scraperwiki\utils.py", line 15, in <module
>
    import urllib, urllib2
ImportError: No module named 'urllib2'
drj11 commented 10 years ago

We don't yet support Python 3.x