python网络编程之http协议-数据提交
编写程序实现通过有道或百度翻译url对用户输入数据进行翻译: 进入有道翻译或者百度翻译页面,找出页面向服务器提交待翻译数据使用的url; 使用浏览器分析工具分析相关需要提交的数据字段以及值,主要包括:(1)待翻译词语或句子使用的字段数据;(2)待翻译数据使用的语言;(3)翻译结果使用的语言;(4)返回的翻译结果使用的数据类型;(5)其他需要的数据字段 获取使用requests库post方法提交数据所需其他数据,如headers中使用的数据信息(如User-Agent,cookies等) 实现完整的程序,并运行程序,对输入的待翻译的内容的返回结果进行验证;如果出现返回为空值等问题,请对可能的原因进行分析,并给出可行的解决方案。
python网络编程之http协议-数据请求
编写程序实现新闻网页数据的请求和获取数据的保存: 进入一个学校的新闻首页,分析各不同新闻网页url之间的区别和联系,并根据得到的规律通过程序生成所要请求的网页的url(前30个页面)。 使用requests库通过http协议的get方法向web server 请求30个页面的数据,要求:(1)30个请求分别由5个线程实现,每个线程负责6个url页面的请求;(2)每个线程中的不同页面请求的时间间隔是3秒;(3)当线程中成功获取某一个新闻网页数据后,需要在屏幕上输出相应的状态信息(如。。。网页请求成功) 对于每个获取的网页数据,分别将其写入到本地相应的html文件中,要求本地网页数据文件的文件名为pageXXX(XXX为请求页面的编号) 对生成的文件进行验证,如果出现中文乱码的问题,请对可能的原因进行分析,并给出可行的解决方案。
python网络编程之服务器架构
编写程序分别实现服务端和客户端要求功能 服务器能够使用TCP协议同时为多台客户端主机提供部分电影的演员信息查询服务(基于多线程或者异步通信): 服务端启动后,需先建立数据结构来存储从movieResult.csv文件中读入的电影数据,并建立socket对象监听客户端的TCP连接请求,如有请求便同意与客户端建立tcp连接 客户端运行时能够提示并接收用户输入的电影名称,并将电影名称数据传递给服务器(需与服务器建立tcp连接) 服务器接收到客户端传递的电影名称后,查询读入的电影数据,如果没有该电影的演员信息则返回没有该电影数据!,如果有该电影的演员信息则返回该电影的主演信息 客户端接收到返回的查询结果后在屏幕上输出相应的结果 服务器为同一客户端提供连续查询服务的时间间隔为5秒
python网络编程之网络数据与网络错误
服务器端和客户端IP:当前主机IP
分析给定通信程序中的client端和server端代码,对出现的粘包问题进行简单描述并分析出现的原因
设计一个方案解决通信中的粘包问题
对client端和server端程序进行修改,并验证方案的正确性
UDP c/s结构通信 扫描主机端口状态
UDP c/s结构通信
服务器端和客户端IP:当前主机IP(192.168.?.?)
服务器监听端口:服务器启动时默认侦听端口为1060,当客户端有udp数据传过来时,可以对数据进行解码(utf-8)并打印出客户端传输的字符串数据,同时给发送数据的客户端传输字符串数据“你好,我是服务器+(ip,port),有事情可以随时联系我!”
客户端端口:系统随机选定(范围为10000-20000)。
要求客户端启动后给服务器发送一个字符串数据“服务器你好,我是客户端+(ip,port)”,发送完数据后客户端便处于等待服务器端使用udp协议回复信息状态,接收到回复信息后,在屏幕上输出解码后的数据。
扫描主机端口状态
建立程序能够对本机的常用接口状态进行检测,并将扫描到的活动端口信息写入到scanResult.txt文件中
常用的端口列表portLs=[21, 22, 23, 25, 80, 135, 137, 139, 445, 1433, 1502, 3306, 3389, 8080, 9015]
Library.zip
以下提供数据库建立文件
/*
Navicat MySQL Data Transfer
Source Server : localhost_3306
Source Server Version : 80013
Source Host : localhost:3306
Source Database : db_books
Target Server Type : MYSQL
Target Server Version : 80013
File Encoding : 65001
Date: 2018-12-21 12:55:28
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for tb_books-
-- ----------------------------
DROP TABLE IF EXISTS `tb_books`;
CREATE TABLE `tb_books` (
`ID` int(255) unsigned NOT NULL AUTO_INCREMENT,
`ISBN` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`book_name` varchar(255) DEFAULT NULL,
`book_price` decimal(10,2) DEFAULT NULL,
`book_author` varchar(255) DEFAULT NULL,
`published_house` varchar(255) DEFAULT NULL,
`book_category` varchar(255) DEFAULT NULL,
`borrower_name` varchar(255) DEFAULT NULL,
`borrower_phone` varchar(255) DEFAULT NULL,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
-- ----------------------------
-- Records of tb_books
-- ----------------------------
INSERT INTO `tb_books` VALUES ('1', '978-7-100-10618-4', 'Othello', '56.00', 'W. William Shakespeare', 'Shanghai World Book Publishing Company', 'G792', 'Mark', '13503383632');
INSERT INTO `tb_books` VALUES ('2', '978-7-111-29544-0', 'BBC Doctor Who: 12 Doctors, 12 Stories ,12 Postcards', '69.00', ' BBC', ' BBC', 'TP312', 'Mark', '13503383632');
INSERT INTO `tb_books` VALUES ('3', '978-7-115-21687-8', 'The Poetry of Pablo Neruda', '59.00', 'Pablo Neruda,Ilan Stavans,Firuz Kazemzadeh', ' FSG BOOKS', 'TP311.5', null, null);
INSERT INTO `tb_books` VALUES ('5', '978-7-300-11134-6', 'Cereal City Guide PARIS CITY GUIDE', '59.00', 'Rich Stapleton', ' Cereal Magazine', 'F830', null, null);
INSERT INTO `tb_books` VALUES ('6', '978-7-302-23755-6', 'Cereal City Guide Copenhagen CITY GUIDE', '36.00', ' Rich Stapleton', ' Cereal Magazine', 'TP312', null, null);
INSERT INTO `tb_books` VALUES ('7', '978-7-302-27544-2', 'George W. Bush And the Southern Takeover of American Politics', '29.00', 'Michael Lind', 'New America Books', 'TP312', null, null);
INSERT INTO `tb_books` VALUES ('8', '978-7-302-29391-0', 'How Liberals Hurt Those They Claim to Help', '34.50', 'Mona Charen', ' Sentinel', 'TP393.0', 'Mark', '13503383632');
INSERT INTO `tb_books` VALUES ('9', '978-7-5117-0157-2', 'Lincoln in the Bardo', '16.00', 'George Saunders', 'Bloomsbury Publishing PLC','I', null, null);
INSERT INTO `tb_books` VALUES ('10', '978-7-5327-5110-5', 'A Song of Ice and Fire Box Set', '58.00', 'George R. R. Martin',' HarperCollins UK','I', null, null);
INSERT INTO `tb_books` VALUES ('11', '978-7-5399-3321-4', 'The New World Champion Paper Airplane Book','28.50', 'John M. Collins',' Ten Speed Press', 'I207.23', null, null);
INSERT INTO `tb_books` VALUES ('23', '978-7-5399-5488-2', 'Introduction to Linear Algebra', '34.00', 'Gilbert Strang', ' Wellesley College', 'I', null, null);
-- ----------------------------
-- Table structure for tb_user
-- ----------------------------
DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user` (
`id` int(255) unsigned NOT NULL AUTO_INCREMENT,
`user` varchar(255) DEFAULT NULL,
`passwd` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
-- ----------------------------
-- Records of tb_user
-- ----------------------------
INSERT INTO `tb_user` VALUES ('1', 'root', 'root');
cp201x资源启动程序
Install driver for USB-UART bridge converter on Linux Ubuntu12.04
Ubuntu下USB转串口芯片驱动程序安装,支持cp210x,pl2303等
Reference: Fixing the cp210x open - Unable to enable UART Error
When you plugin your USB-UART converter, and run "> ls /dev/tty*", if you don't see the /dev/ttyUSB0 (or similar), your Linux does not detect your USB-UART device.
We need to install the driver for your device.
Here we use Ubuntu12.04, and Updated the source to 3.2.0 version. If there is difference about version Number from your OS platform, please try to modify it into yours.
1.Download the Linux Source Code
Open a terminal and execute the following commands. Note that your version of Linux may differ slightly -- adjust accordingly.
$ cd ~
$ sudo apt-get install build-essential linux-source
$ cp /usr/src/linux-source-3.2.0.tar.bz2 .
$ bunzip2 linux-source-3.2.0.tar.bz2
$ tar xf linux-source-3.2.0.tar
$ cd ~/linux-source-3.2.0
2.Recompile and Reinstall the cp210x Driver
From within a terminal, execute:
$ cd ~/linux-source-3.2.0
$ make oldconfig
$ make prepare
$ make scripts
$ cp /usr/src/linux-headers-3.2.0-34-generic-pae/Module.symvers .
Here, I have the "3.2.0-29" version also, I launched the command above, but not the below:
"cp /usr/src/linux-headers-3.2.0-29-generic-pae/Module.symvers ."
Recompile and Reinstall the cp210x Driver
Here, We can actually install many kinds of USB-UART converter drivers. We take cp210x as the example.
From within a terminal, execute:
$ make M=drivers/usb/serial
$ sudo mv /lib/modules/$(uname -r)/kernel/drivers/usb/serial/cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/cp210x.ko.old
$ sudo cp drivers/usb/serial/cp210x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/
$ sudo modprobe -r cp210x
$ sudo modprobe cp210x
Reboot Linux system.
Run Terminal:
$ ls /dev/tty*
The we can see the device is detected by Linux Host OS:
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
Reference: http://pharos.ece.utexas.edu/wiki/index.php/Fixing_the_cp210x_open_-_Unable_to_enable_UART_Error_-_04/17/2011
Then, We can configure the minicom to communicate with our target board.
======================================================
Here is an example of configure the parameters of minicom for TLL6527M PAL board:
I just copied it here hardly without any font editing. Sorry about that.
Serial Communications from Host-PC to TLL6527M Target Hardware
The TLL System Design Environment (SDE) running on the host PC comes pre-configured with the required settings for serial-UART communications between the host PC and the TLL6527M base module. Generally, for use with TLL6527M the settings need not to be changed (Note: From the SDE OS version 0.3.2, the serial terminal program Minicom is set to open /dev/ttyUSB0 with the needed configuration as mentioned above.).
To start serial communication from host to the TLL6527M, open the serial communication terminal program Minicom. Just open a terminal window on your Linux SDE running on the host PC and type the command "minicom" at the command prompt on your host PC terminal console.
The TLL6527M on power-up is set by default to the following serial-UART communication settings:
Bits per second = 115200
Data bits = 8
Parity = None
Stop Bits = 1
Flow control = None
Make sure that the TLL6527M's USB-UART port has been mapped to a ttyUSBx device node in the /dev folder on the host PC SDE. See following example:
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
Now make sure that this "ttyUSBx" is set as the destination port, baud rate is 115200, and 8N1 mode for minicom, by running the command 'minicom -s'. Note that running the "minicom -s" command as a normal user will only apply the settings for the current session. In order to make the settings permanent, these commands need to be run with root privileges.See example below:
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
The following window will appear on your host PC terminal window:
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
Go to ‘Serial port setup’, following screen will appear, make sure that serial device is set to ‘/dev/ttyUSB0’ and bps/par/bits is set to 115200 8N1:
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
Now go back to the main menu and choose ‘save setup as dfl’. This will save the configuration settings and from next time onwards user can directly run ‘minicom’ command without the option ‘–s’ and it will load settings from the saved file.
【技术】Ubuntu下USB转串口芯片驱动程序安装cp210x,pl2303
RESET the target by using the SDE's TLL6527M reset utility or by pressing the RESET button on the target.
Following messages will be displayed on the terminal. By default, U-Boot is setup to automatically start booting the OS after waiting for a few seconds for the user to interrupt the automatic launch by pressing any key. So to stop U-Boot from loading uClinux and provide U-Boot command prompt, just hit any key. (This is assuming TLL6527M is flashed with u-boot and uClinux. TLL6527Ms are pre-flashed with firmware before shipping).