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
from urllib.parse import urlencode | |
def extract_form_fields(self, soup): | |
"Turn a BeautifulSoup form into url encoded fields and default values" | |
fields = "" | |
for input in soup.findAll('input'): | |
# ignore submit/image with no name attribute | |
if input['type'] in ('submit', 'image') and not input.has_attr('name'): | |
continue | |
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
from urllib.request import urlopen | |
from bs4 import BeautifulSoup | |
webpage = urlopen('https://www.google.com') | |
soup = BeautifulSoup(webpage) | |
print(soup.prettify()) |
NewerOlder