-
-
Save attacker34/80d8d1af4c9a40dc1c8cd659c6a1a9f6 to your computer and use it in GitHub Desktop.
Extract links from a given html document with you must call as first argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sys | |
from lxml import html | |
def main(): | |
filename = sys.argv[1] | |
with open(filename, 'rb') as f: | |
lines = f.readlines() | |
line = ','.join(lines) | |
str = html.document_fromstring(line) | |
x = str.xpath('//a/@href') | |
with open('urls.txt', 'wb') as f: | |
for i in x: | |
f.write('{}\n'.format(i)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment