Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Python Network Programming Cookbook

You're reading from   Python Network Programming Cookbook Practical solutions to overcome real-world networking challenges

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781786463999
Length 450 pages
Edition 2nd Edition
Languages
Tools
Concepts
Arrow right icon
Authors (2):
Arrow left icon
Pradeeban Kathiravelu Pradeeban Kathiravelu
Author Profile Icon Pradeeban Kathiravelu
Pradeeban Kathiravelu
Dr. M. O. Faruque Sarker Dr. M. O. Faruque Sarker
Author Profile Icon Dr. M. O. Faruque Sarker
Dr. M. O. Faruque Sarker
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Dedication
Preface
1. Sockets, IPv4, and Simple Client/Server Programming FREE CHAPTER 2. Multiplexing Socket I/O for Better Performance 3. IPv6, Unix Domain Sockets, and Network Interfaces 4. Programming with HTTP for the Internet 5. Email Protocols, FTP, and CGI Programming 6. Programming Across Machine Boundaries 7. Working with Web Services – XML-RPC, SOAP, and REST 8. Network Monitoring and Security 9. Network Modeling 10. Getting Started with SDN 11. Authentication, Authorization, and Accounting (AAA) 12. Open and Proprietary Networking Solutions 13. NFV and Orchestration – A Larger Ecosystem 14. Programming the Internet

Submitting web forms


During web browsing, we submit web forms many times in a day. Now, you would like do that using the Python code.

Getting ready

This recipe uses a third-party Python module called requests. You can install the compatible version of this module by following the instructions from http://docs.python-requests.org/en/latest/user/install/. For example, you can use pip to install requests from the command line as follows:

$ pip install requests

How to do it...

Let us submit some fake data to register with https://twitter.com/. Each form submission has two methods: GET and POST. The less sensitive data, for example, search queries, are usually submitted by GET and the more sensitive data is sent via the POST method. Let us try submitting data with both of them.

Listing 4.4 explains the submit web forms, as follows:

#!/usr/bin/env python 
# Python Network Programming Cookbook -- Chapter - 4 
# This program requires Python 3.5.2 or any later version 
# It may run on any other version...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime
Banner background image