[Spark] [Python] Example of a dataframe in which a limited record is taken:SqlContext = Hivecontext (SC)PEOPLEDF = SqlContext.read.json ("People.json")Peopledf.limit (3). Show ()===[Email protected] ~]$ HDFs dfs-cat People.json{"Name": "Alice", "Pcode": "94304"}{"Name": "Brayden", "age": +, "Pcode": "94304"}{"Name": "Carla", "age": +, "Pcoe": "10036"}{"Name": "Di
Example of the RDD FlatMap operation:FlatMap, performs a function operation on each element (line) of the original Rdd, and then "beats" each line[Email protected] ~]$ HDFs dfs-put cats.txt[Email protected] ~]$ HDFs dfa-cat cats.txtError:could not find or load main class DFA[Email protected] ~]$ HDFs dfs-cat cats.txtTh
. code) # add the mail method mail (e. code) failed t urllib. error. URLError as err: print (err. reason) # add the mail method mail (err. reason)
Done!
Conclusion
There are only 50 lines of code, and the program can be improved:
For example, the agent list is automatically obtained, the interface is added, and multithreading is extended.
Finally, I would like to share my work with other friends.
import urllib2import timeitimport thread import timei =
default content inherited from Base.html is displayed. {% Block content%}{% include'ad.html'%} #引用ad. html template. this isIndex page,welcome! {% Endblock%}Change the function that processes the request to return the template file to the client: (Of course, the content is rendered)In the app/views.py from Import def Home (Request): return'home.html' )Viii. Start-up project:[email protected] mysite]$Python
POST login. 3, password some are sent in clear text, some are sent after encryption. Some websites even use dynamic encryption, including a lot of other data encryption information, only by viewing the JS source code to obtain encryption algorithm, and then to crack encryption, very difficult. 4, most Web sites are similar to the overall process, there may be some different details, so there is no guarantee that the other site login Success III, using selenium and Phantomjs
:53 2016Thread-3 starting at Tue Dec 20 23:22:53 2016Thread-4 starting at Tue Dec 20 23:22:53 2016Thread-5 starting at Tue Dec 20 23:22:53 2016Thread-6 starting at Tue Dec 20 23:22:53 2016Thread-1 end at Tue Dec 20 23:22:55 2016Remaining thread-2,thread-3,thread-4,thread-5,thread-6Thread-4 end at Tue Dec 20 23:22:55 2016Remaining thread-2,thread-3,thread-5,thread-6Thread-2 end at Tue Dec 20 23:22:55 2016Remaining thread-3,thread-5,thread-6Thread-5 end at Tue Dec 20 23:22:56 2016Remaining thread-
-8ImportSockethost="'Port= 51421s=Socket.socket (socket.af_inet, socket. SOCK_STREAM) s.setsockopt (socket. Sol_socket, SOCKET. SO_REUSEADDR,1) S.bind ((host, Port)) S.listen (1)#there's only one waiting to be processed at a timePrint "Server is running on port%d, press Ctrl-c to terminate."%Port while1: Clientsock, Clientaddr=s.accept () clientfile= Clientsock.makefile ('RW', 0) clientfile.write ("Welcome,"+ STR (CLIENTADDR) +"\ n") Clientfile.write ("Please enter a string:") Line=clientfile.re
This article mainly describes the Python read the message data and download an example of the attachment of the relevant information, here to provide an example of implementation, to help you learn to understand this part of the content, the need for friends can refer to the following
Detailed Python implementation re
First QQ Mail with a third-party client sent to request a verification code. Instead of the QQ password.The authorization code is the password you want to use to sign in nextThen the rest of the work is very simple. The following simple code is attached:#coding: Utf-8import smtplibfrom email.mime.text Import mimetext_user = "[email protected]" _pwd = "12341234134" # Use the authorization code _to = "[email
subclasses can implement data persistence, define save, load, revert three interfaces.
Mozillacookiejar LwpcookiejarTwo implementation classes, the inheritance relationship is as follows:Mozillacookiejar Lwpcookiejar
II. Use
Simple exampleA simple code of use#!/usr/bin/env python# Encoding:utf-8Import requestsImport Cookieliburl = ' http://www.baidu.com/'Jar = Cookielib. Lwpcookiejar (' Cookie.txt ')# Try to load cookies# Ask a question, why do yo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.