![]() |
|
[Python] Whois script help - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Whois script help (/showthread.php?tid=4872642) |
Whois script help - Culperring722 - Jun 19, 2015 Okay i can get the whois info to out put to the screen but I'm having problems saving to a text file. It isn't saving any of the output in the text file for some reason. Maybe someone could help me Code from subprocess import callIm only having problems saving output to txt file. I know how to save output to text files normally but its not working in this case for some reason. If no one can help ill just make a webscrapper and do it that way. * - totenkopf - Jun 19, 2015 Usually you have to specify it as a text file, were you writing it and getting a blank file? Not sure why you do with open and as output but you'd do: output=your stuff from before filename=raw_input("Text file name: ") outputfile=open(filename+".txt", "w") outputfile.write(output) I tried the above with "a" but I wasn't able to write to the text file, when switched to "w" it worked properly. You can then use outputfile.read() to skim whatever you need if you intend on expanding your script to fetch and automate things. edit: don't name one of your strings "file" either as it's reserved for other things. I didn't bother to install your modules to test it out but this should work: Code from subprocess import call* - selinux - Jun 19, 2015 You realize that there is a Whois library right? It would make your life so much easier. * - Culperring722 - Jun 19, 2015 (Jun 19, 2015 08:33 PM)selinux Wrote: You realize that there is a Whois library right? Nope i didn't know that haha ill try that (Jun 19, 2015 08:19 PM)Totenkopf Wrote: Usually you have to specify it as a text file, were you writing it and getting a blank file?Umm ya I'm still getting a blank file for some reason. C can output to a file when i don't use the subprocess module but for some reason the call(["whois", IP]) seems to be preventing me from saving its out put to a file i can only print it to the screen. I think ima just used the whois library instead of trying to re invent the wheel. * - TreaZon - Jun 19, 2015 I've made a similar program to this. It uses Whatismyipaddress to get information on an IP in command line. You can easily reuse it to work with or another whois lookup site. Replace the [dot] with actual dots... (Can't post links/etc bullshit) Enjoy! Code #!/usr/bin/env python* - Introvert - Jun 20, 2015 OP, just make your life easy and use some of the many whois python libraries. ipwhois seems to work well: Code from ipwhois import IPWhois* - selinux - Jun 20, 2015 (Jun 19, 2015 10:22 PM)TreaZon Wrote: -Snip- You can do that in literally 1 line... Code for k, v in (__import__('json').loads((__import__('requests').get('http://www.telize.com/geoip/' + __import__('sys').argv[1]).text))).items(): print '%s: %s' % (k, v)That's the most retarded script I've seen no offense 😉 * - Emoticon - Jun 22, 2015 (Jun 20, 2015 10:51 AM)selinux Wrote: You can do that in literally 1 line... Yeah, because geoip is the same thing as whois. That's the most retarded script I've seen no offense 😉 oh wait he's closed he won't read this lol im gay |