Foundations of Python Network Programming
Chapter 11 ■ the World Wide Web 220 def main(GET): parser = argparse.ArgumentParser(description='Scrape a simple site.') parser. ...
Chapter 11 ■ the World Wide Web 221 Listing 11-14. Recursively Scraping a Web Site with Selenium !/usr/bin/env python3 Foundatio ...
Chapter 11 ■ the World Wide Web 222 The scraper is thus able to find every single page on the site despite that some links are l ...
223 Chapter 12 Building and Parsing E-Mail This is the first of four chapters on the important topic of e-mail. This particular ...
Chapter 12 ■ Building and parsing e-Mail 224 • E-mail is represented as plain ASCII text, using character codes 1 through 127 ...
Chapter 12 ■ Building and parsing e-Mail 225 to pele, which probably performed e-mail transmission either for a department or fo ...
Chapter 12 ■ Building and parsing e-Mail 226 text = """Hello, This is a basic message from Chapter 12. Anonymous""" def main() ...
Chapter 12 ■ Building and parsing e-Mail 227 If you were to build an e-mail message using the old Message class instead of Email ...
Chapter 12 ■ Building and parsing e-Mail 228 • add_alternative() can then be called zero or more times to provide other rende ...
Chapter 12 ■ Building and parsing e-Mail 229 message.add_related(blue_dot, 'image', 'gif', cid=cid, filename='blue-dot.gif') mes ...
Chapter 12 ■ Building and parsing e-Mail 230 To: Test Recipient
[email protected]
From: Test Sender
[email protected]
Subje ...
Chapter 12 ■ Building and parsing e-Mail 231 You can see all of these mechanisms in play together by examining the following out ...
Chapter 12 ■ Building and parsing e-Mail 232 --===============0086939546== Content-Type: text/plain; charset="utf-8" Content-Tra ...
Chapter 12 ■ Building and parsing e-Mail 233 • method(..., cte='quoted-printable') All of these methods seem to default to on ...
Chapter 12 ■ Building and parsing e-Mail 234 try: body = message.get_body(preferencelist=('plain', 'html')) except KeyError: pri ...
Chapter 12 ■ Building and parsing e-Mail 235 $ python3 build_basic_email.py > email.txt $ python3 display_email.py email.txt ...
Chapter 12 ■ Building and parsing e-Mail 236 • When examining a normal part, the Content-Disposition header will tell you whe ...
Chapter 12 ■ Building and parsing e-Mail 237 You can exercise this script against any of the e-mail messages that the earlier sc ...
Chapter 12 ■ Building and parsing e-Mail 238 def main(): message = email.message.EmailMessage(email.policy.SMTP) message['To'] = ...
Chapter 12 ■ Building and parsing e-Mail 239 Parsing Dates Standards-compliant dates were used in the scripts above through the ...
«
7
8
9
10
11
12
13
14
15
16
»
Free download pdf