Reputation: 7 Worker
- Active Posts:
- 824 (0.2 per day)
- 22-November 04
- Profile Views:
- Last Active:
- Sep 19 2015 03:27 PM
- Who Cares
- OS Preference:
- Favorite Browser:
- Favorite Processor:
- Favorite Gaming Platform:
- Your Car:
- Dream Kudos:
Posts I've Made
Posted 19 Sep 2015Omg... That just made me feel stupid:
./scrape.py http://google.com http://www.google.com/imghp?hl=en&tab=wi http://maps.google.com/maps?hl=en&tab=wl https://play.google.com/?hl=en&tab=w8 http://www.youtube.com/?tab=w1 http://news.google.com/nwshp?hl=en&tab=wn https://mail.google.com/mail/?tab=wm https://drive.google.com/?tab=wo http://www.google.com/intl/en/options/ http://www.google.com/history/optout?hl=en http://google.com/preferences?hl=en https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com/ http://google.com/chrome/browser/?hl=en&brand=CHNG&utm_source=en-hpp&utm_medium=hpp&utm_campaign=en http://google.com/advanced_search?hl=en&authuser=0 http://google.com/language_tools?hl=en&authuser=0 http://google.com/intl/en/ads/ http://google.com/services/ https://plus.google.com/116899029375914044550 http://google.com/intl/en/about.html http://google.com/intl/en/policies/privacy/ http://google.com/intl/en/policies/terms/ Nuber of total URLs: 20
Switching from night to day shift does not help my logic capabilities. Thank you for your patience.
Posted 19 Sep 2015
Quoteargv is a list (what made you think it was a single value?)
I didn't know it was an actual list, but that makes sense. I changed this line to the following :
httpResponse = urllib.urlopen(sys.argv)
Now I'm suddenly being asked for a file or directory?
$ ./scrape.py google.com Traceback (most recent call last): File "./scrape.py", line 18, in <module> httpResponse = urllib.urlopen(sys.argv) File "/usr/lib/python2.7/urllib.py", line 86, in urlopen return opener.open(url) File "/usr/lib/python2.7/urllib.py", line 207, in open return getattr(self, name)(url) File "/usr/lib/python2.7/urllib.py", line 462, in open_file return self.open_local_file(url) File "/usr/lib/python2.7/urllib.py", line 476, in open_local_file raise IOError(e.errno, e.strerror, e.filename) IOError: [Errno 2] No such file or directory: 'google.com'
I tried str(sys.argv) with the same results. Maybe the library requires a file for this? Or maybe I'm still doing it wrong
Thanks for the suggestion!
Posted 28 Feb 2014That dawned on me while I was away for my computer a couple hours.
Good call though. Derp!
Posted 28 Feb 2014I see what you mean. I took out the [^127.0.0.1] like so:
#!/usr/bin/python import re import subprocess from subprocess import Popen, PIPE pattern = re.compile(r'inet.*\d+\.\d+\.\d+\.\d+') p1 = Popen(["/sbin/ifconfig"], stdout=subprocess.PIPE) output = p1.communicate() result = re.findall(pattern, output) print result
And a line with 127.0.0.1 is all I get:
# ./test.py inet addr:127.0.0.1 Mask:255.0.0.0
Would you happen to know why its finding 127.0.0.1, but missing 10.0.0.139 listed on my other interface?
wlan2 Link encap:Ethernet HWaddr 00:1f:1f:7e:a3:de inet addr:10.0.0.139 Bcast:10.0.0.255 Mask:255.255.255.0 inet6 addr: fe80::21f:1fff:fe7e:a3de/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:19712 errors:0 dropped:0 overruns:0 frame:0 TX packets:17179 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:14323745 (13.6 MiB) TX bytes:3351821 (3.1 MiB)
Thanks for getting me this far.
Posted 22 Feb 2014Nice! Guess I have a lot more to learn about debugging with Python. The "from array import *" was something I found searching for arrays, but it seems to work fine without it. Thank you both!
- Member Title:
- D.I.C Addict
- Age Unknown
- Birthday Unknown
- Years Programming:
- Programming Languages:
- C, Python, Perl, Ruby, Bash HTML, CSS, PHP, MySQL
- Click here to e-mail me