trumpquotegif

trump quote gif

mashup of trump trump quotes and gifs

Hillary Clinton Email Archive API. Merge with Trump Quotes, giphy and natural language toolkit.

In [ ]:
 
In [3]:
import giphypop
import random
import requests
import json
import getpass
import arrow
import nltk
In [4]:
#nltk.download()
In [6]:
from nltk.book import *
*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908
In [7]:
text2.concordance('angry')
Displaying 12 of 12 matches:
by turning very red and saying in an angry manner to Margaret , " Remember that
 perfectly true . Marianne was quite angry with her for doubting it . " Why sho
er severely ; she was vexed and half angry ; but resolving to regulate her beha
mfortable . I felt sure that you was angry with me ; and have been quarrelling 
e had rather expected all along ; so angry at their accepting her mother ' s in
 . Palmer , in her way , was equally angry . " She was determined to drop his a
d . Mrs . Ferrars looked exceedingly angry , and drawing herself up more stiffl
on ' s daughter ." Fanny looked very angry too , and her husband was all in a f
 as well as great ." Elinor was very angry , but Marianne seemed entirely insen
ings has heard all about it . Is she angry ?" " Not at all , I believe , with y
 thing . And Lady Middleton , is SHE angry ?" " I cannot suppose it possible th
urning her eyes on him with the most angry contempt , stopped him , by saying ,
In [8]:
#ransam = random.sample(theful, 10)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-82b8afc1dad2> in <module>()
----> 1 ransam = random.sample(theful, 10)

NameError: name 'theful' is not defined
In [ ]:
#ransam
In [41]:
#len(brown.words())
Out[41]:
1161192
In [ ]:
ranshuf[50]
In [39]:
random.choice(brown.words())
Out[39]:
'already'
In [ ]:
from nltk.corpus import brown
In [ ]:
for bro in brown.words():
    print(bro)
In [ ]:
from mltk.book import * 
In [35]:
myusr = getpass.getuser()
In [36]:
myusr
Out[36]:
'wcm'
In [9]:
trumpreq = requests.get('https://api.whatdoestrumpthink.com/api/v1/quotes')
In [10]:
trumpdict = json.loads(trumpreq.text)
In [11]:
rannopers = random.choice(trumpdict['messages']['non_personalized'])
In [ ]:
 
In [12]:
ranpers = random.choice(trumpdict['messages']['personalized'])
In [13]:
#rannopers.replace('I', )
In [14]:
ranpers
Out[14]:
'has failed miserably'
In [15]:
leakurl = 'https://www.leaksapi.com/clinton-emails/from/8a52166f-1ff2-4060-9215-3583895df339'
In [16]:
leku = requests.get(leakurl)
In [17]:
allusers = json.loads(leku.text)
In [18]:
rannopers
Out[18]:
'Why can’t we use nuclear weapons?'
In [ ]:
 
In [19]:
print(rannopers.replace('America', 'Hogwarts'))
Why can’t we use nuclear weapons?
In [20]:
for allus in allusers:
    lanpers = random.choice(trumpdict['messages']['personalized'])
    #print('{} {}'.format(allus, lanpers))
    #toke = nltk.word_tokenize('{} {}'.format(allus, lanpers))
    #print(toke)
    lpaz = ('{} {}'.format(allus, lanpers))
    print(lpaz.upper())
    #print(rannopers.replace('I', lanpers))
HILLARY CLINTON IS DESPERATE
 BOMBED LAST NIGHT!
OPINION RESEARCH COULDN'T GET ELECTED DOG CATCHER
SIDNEY BLUMENTHAL IS A DOPEY CLOWN
WASHINGTON POST ATTACKED NEW YORKERS AND NEW YORK VALUES- WE DON'T FORGET!
CHELSEA CLINTON WROTE LETTER TO ME BEGGING FOR FORGIVENESS
MIKE IS WEAK AND TOTALLY CONFLICTED
MELANNE VERVEER IS A TOTAL LOSER
HUMA ABEDIN HAS THE ABSOLUTELY WORST ANTI-TRUMP TALKING HEADS ON HIS SHOW
CHERYL MILLS REMINDS ME OF A SPOILED BRAT WITHOUT A PROPERLY FUNCTIONING BRAIN
JAMA HAS WORST VOTING RECORD IN SENATE
PHILIPPE REINES LIES SO MUCH AND IS SO DISHONEST
JUDITH MCHALE IS TRYING TO EXTORT $1,000,000.00 FROM ME
MIGUEL RODRIGUEZ REALLY WENT WACKO TODAY
ANNE-MARIE SLAUGHTER IS NOT VERY PRESIDENTIAL
RICHARD VERMA IS PERFECT LITTLE PUPPET
STROBE TALBOTT IS SLOPPY
JUDITH KIEFFER , YOU HAVE NO IDEA WHAT MY STRATEGY ON ISIS IS
JAKE SULLIVAN ONLY WON THE DEBATE IN THE MINDS OF DESPERATE PEOPLE
PIPER CAMPBELL REALLY WENT WACKO TODAY
DANIEL SCHWERIN IS NOT LOOKING SMART
LAUREN JILOTY TOTALLY SOLD OUT
ROBERT RUSSO SPENT $1,000 TO REGISTER IN NEW HAMPSHIRE & DROPPED OUT THE NEXT DAY. SUCH A WASTE!
DANA HYDE JUST DOESN'T KNOW ABOUT WINNING
JAMES SMITH HAD ZERO IN HIS PRESIDENTIAL RUN BEFORE DROPPING OUT IN DISGRACE
PHILIP CROWLEY MAY BE THE MOST CORRUPT PERSON EVER TO SEEK THE PRESIDENCY
MONICA HANLEY WILL ALLOW ANYONE INTO THE COUNTRY
HEINTZ IS JUST A DISHONEST GUY
JOSHUA DANIEL GOT THROWN OFF OF TV BY NBC
TODD STERN IS GETTING MORE AND MORE BIASED
MADELEINE ALBRIGHT IS GETTING MORE AND MORE BIASED
DANIEL INONYE IS TRYING TO EXTORT $1,000,000.00 FROM ME
PHILLIP CROWLEY KNOWS NOTHING ABOUT ME OR MY RELIGION
ELLEN TAUSCHER KNOWS NOTHING ABOUT ME OR MY RELIGION
JEFFREY FELTMAN BOMBED LAST NIGHT!
MICHAEL FUCHS IS ONE OF THE DUMBEST PEOPLE IN POLITICS
HAROLD HONGJU KOH IS EXHAUSTED
BETSY EBELING IS NOT QUALIFIED
ERIC WOODARD NEVER MADE TEN CENTS
MEGAN ROONEY SUFFERS FROM PLAIN OLD BAD JUDGEMENT!
CHESTER CROCKER CAME IN DEAD LAST
SAMUEL BERGER IS A TOY BY COMPARISON
JACOB LEW IS A TOTAL #MEDIAFRAUD
LOIS QUAM IS GRUBBY
ANDREW SHAPIRO IS SO UNBELIEVEABLY CROOKED
KURT CAMPBELL DOES NOT HAVE THE STRENGTH OR STAMINA TO BE PRESIDENT
PHILIP GORDON IS AN ESTABLISHMENT FLUNKY
ACLB GOT THROWN OFF OF TV BY NBC
NEERA TANDEN HAS GONE WILD WITH HATE
LISSA MUSCATINE COULDN'T EVEN RESPOND PROPERLY TO PRESIDENT OBAMA'S STATE OF THE UNION SPEECH WITHOUT POURING SWEAT & CHUGGING WATER
MARIA OTERO IS A TOTAL HYPOCRITES!
LONA VALMORO IS DOING MANY BAD THINGS BEHIND OUR BACKS
JAMES STEINBERG IS A DOPEY CLOWN
DAVID BROCK WASTED $400 MILLION
GEORGE MITCHELL IS VERY WEAK ON ILLEGAL IMMIGRATION
CAPRICIA MARSHALL REGISTERED AT LESS THAN 1 PERCENT IN THE POLLS
VODA EBELING IS READING POORLY FROM THE TELEPROMTER!
DAILY SUN IS A DISGUSTING FRAUD
MARIA CALIVIS IS A FAILED JEB BUSHY
AMERICAN BEVERAGE ASSOCIATION HAS BAD JUDGEMENT
ANTHONY LAKE NEVER MADE TEN CENTS
POSTMASTER@STATE.GOV HAS DONE SUCH A COMPLETE FOLD
BARBARA MIKULSKI ONLY WON THE DEBATE IN THE MINDS OF DESPERATE PEOPLE
ARTURO VALENZUELA NO LONGER HAS CREDIBILITY
CLAIRE COLEMAN IS A TOTAL LOSER
ALCB WAS RAN OUT OF THE RACE LIKE A LITTLE BOY
LATIMES.COM BETRAYED BERNIE VOTERS
DAVID MILIBAND WILL DO ANYTHING TO STAY AT THE TROUGH
BURNS STRIDER COULDN'T GET ELECTED DOG CATCHER
KRIS BALDERSTON IS A HIGHLY OVERRATED POLITICIAN
JONATHAN PRINCE IS REALLY HARD TO WATCH, HAS ZERO TALENT
STATE IS VERY DUMB AND FAILING
S. AKBAR ZAIDI WILL ALLOW ANYONE INTO THE COUNTRY
JEFFREY FARROW WOULD BE SO EASY TO BEAT!
LOUISE DIAMOND HAS THE ABSOLUTELY WORST ANTI-TRUMP TALKING HEADS ON HIS SHOW
NEW YORK TIMES IS TOTALLY INEFFECTIVE
SAMUEL (\SANDY\") BERGER" WILL ALLOW ANYONE INTO THE COUNTRY
FOREIGN AFFAIRS MAGAZINE IS TOTALLY INEFFECTIVE & HAS BEEN FOR YEARS
WILLIAM BURNS IS SO UNBELIEVEABLY CROOKED
JOANNE LASZCZYCH SHOULD BE FIRED!
MARIANNE SCOTT HAS ONE OF THE WORST ATTENDANCE RECORD IN SENATE
SUSAN RICE SO TOTALLY WRONG
MAURA PALLY IS TOTALLY UNFAIR
CHERIE BLAIR TRIED TO SHAKE ME DOWN FOR ONE MILLION DOLLARS
AP IS SO TOTALLY DISHONEST!
TSAKINA ELBEGDORI IS A PATHETIC FIGURE!
REINES PHILIPPE IS A DISHONEST LIGHTWEIGHT
ZACHARY ISCOL TRULY DOESN'T HAVE A CLUE!
ROONEYM@STATE.GOV MISREPRESENTS MY POSITIONS!
COURTNEY BEALE IS SOOOOO GUILTY
JAMES MCGOVERN IS DUMB AS A ROCK
ROBERT BLAKE IS SO LITTLE RESPECTED
TOMICAH TILLEMANN CAN NEVER BEAT HILARY CLINTON
CHRISTOPHER BUTZGY HAS ZERO IMAGINATION AND EVEN LESS STAMINA
RECOS TREATS ME SO BADLY
PAYTON KNOPF IS JUST PATHETIC
CECILE RICHARDS CAME TO MY OFFICE LOOKING FOR WORK
RAJIV SHAH IS ONE OF THE DUMBER BLOGGERS
NORA TOIV WANTS RIDICULOUS DEBATE TERMS
PAUL COLLIER HAS A FAULTY THOUGHT PROCESS
ALEX DUPUY IS SO BIASED
LUIS CDEBACA IS REALLY HARD TO WATCH, HAS ZERO TALENT
CASE BUTTON IS ONE OF THE LEAST TALENTED PEOPLE ON TELEVISION
CRAIG KELLY IS A TOTAL DISASTER FOR REPUBLICANS & AMERICA
HAITI HAS A HORRIBLE ATTITUDE
G WILLS GAVE AMNESTY TO CRIMINAL ALIENS GUILTY OF 'SEX OFFENSES.' DISGRACE!
ESTHER BRIMMER HAS NO POWER IN IOWA
DANIEL BAER IS SELLING OUT!
ANDREW MAYOCK GOT ZERO AGAINST ME- NO CRED!
RETA JO LEWIS IS TOTALLY CONTROLLED
SRGIA HAS A NASTY MOUTH
CHAD WESTON IS JUST A 3RD RATE 'GOTCHA' GUY!
MICHAEL POSNER IS A  VERY UNTALENTED REPORTER
ROBERT HORMATS IS A WASTE
CHRISTOPHER GREEN WILL BE FIRED LIKE A DOG
JOHNNIE CARSON SPENT $430 MILLION AND LOST ALL RACES
ANDREA.PALM@HHS.GOV IS ONE OF THE DUMBER BLOGGERS
R_M_GATES REMINDS ME OF A SPOILED BRAT WITHOUT A PROPERLY FUNCTIONING BRAIN
MACMANUS, JOSEPH E IS GETTING MORE AND MORE BIASED
WENDY SHERMAN GRADUATED LAST IN THEIR CLASS
PATRICK KENNEDY IS NOT AS SMART AS CRUZ, AND MAY BE AN EVEN BIGGER LIAR
THOMAS NIDES IS SUCH A MESS
HAMMER, MICHAEL A IS SO BIASED IT IS DISGUSTING
ATWOOD, J BRIAN CAN'T CLOSE THE DEAL WITH BERNIE SANDERS
MON IS SO BIASED IT IS DISGUSTING
MORNINGSTAR, RICHARD L IS A TOTAL #MEDIAFRAUD
CARLOS PASCUAL IS PURE SCUM
DAVID ADAMS IS PART OF THE REPUBLICAN ESTABLISHMENT PROBLEM
KISSINGER, HENRY A IS BOUGHT AND PAID FOR BY WALL STREET, LOBBYISTS AND SPECIAL INTERESTS
FALVO, CHRISTINE ASKED ME FOR EXPENSIVE HOTEL ROOMS
THOMAS DONILON DID A TERRIBLE JOB OF TICKET DISTRBUTION
SULILVAN, JACOB J SPENT $1,000 TO REGISTER IN NEW HAMPSHIRE & DROPPED OUT THE NEXT DAY. SUCH A WASTE!
CROCKER, RYAN C DOESN'T EVEN LOOK PRESIDENTIAL!
SCHU REPORTED 'CRUZ MOMENTUM' BUT NOTHING ABOUT THE FACT THAT I EASILY WON!
REICHEL, CARLYN SHOULD RESIGN
SHERMANWR@STATE.GOV IS JUST PLAIN INCOMPETENT
DSA IS ONE OF THE LEAST PRODUCTIVE U.S. SENATORS
ADAMSDS@STATE.GOV GOES OUT OF THEIR WAY TO DISTORT TRUTH!
ROSS, ALEC J DOESN'T EVEN SHOW UP FOR VOTES!
RUBIN, JAMES P TREATS ME SO BADLY
KERRY, JOHN FELL RIGHT INTO PRESIDENT OBAMA'S TRAP ON OBAMACARE
BARACK OBAMA DOESN'T KNOW HOW TO WIN
ASHTON, CATHERINE WILL NEVER BE ABLE TO HANDLE THE COMPLEXITIES AND DANGER OF ISIS
WHITEHOUSE, SHELDON IS A DOPE!
MISSION.IR SHOULD FOCUS ON FAIR AND BALANCED REPORTING
JALILI, SAEED HAS NO CREDIBILITY
BERNADETTE MEEHAN IS ON A NEW PHONY KICK ABOUT MY MANAGEMENT STYLE
STOCK, ANN WROTE LETTER TO ME BEGGING FOR FORGIVENESS
PATTERSON, ANNE W TRULY DOESN'T HAVE A CLUE!
HANLEY, MONICA LOOKS LIKE A LITTLE BOY ON STAGE
HEINTZ, STEPHEN B KNOWS NOTHING ABOUT ME OR MY RELIGION
DAVIS, LANNY J TRIED TO EXTORT $1,000,000 FROM ME
LANNY DAVIS IS A TOY BY COMPARISON
SULLIVAN. JACOB J IS A MAJOR LIGHTWEIGHT WITH NO CREDIBILITY
NATHANSON, MARC IS AN IRRELEVANT CLOWN, SWEATS AND SHAKES NERVOUSLY
S/CIEA:PASCUAL AND S/EEE MORNINGSTAR WILL NEVER MAKE AMERICA GREAT AGAIN
IVALMORO HAS A WEAKNESS THAT IS THE GREATEST RECRUITING TOOL OF ISIS!!!
TYSON, LAURA WILL BE DEAD IN 2 YEARS
DONILON, THOMAS E. KNOWS NOTHING ABOUT FINANCE
LANG, KIMBERLY C. IS ONE OF THE DUMBEST OF ALL PUNDITS
ROSS, DENNIS B. WILL NEVER MAKE AMERICA GREAT AGAIN
JAMIE IS A TOTAL PHONY
THOMAS_E._DONILON GAVE UP AND ENLISTED MOMMY AND HIS BROTHER
DENNIS ROSS WON'T EVEN CALL IT WHAT IT IS - RADICAL ISLAM!
DAVID HALE BEGGED ME FOR ADS
JILOTY, LARUEN C CONSISTENTLY FUMBLES & MISREPRESENTS POLL RESULTS
HICKEY, CINDY HAS EMBARRASSED ALL BY MAKING VERY DUMB POLITICAL STATEMENTS ABOUT ME
MCHALD, JUDITH A IS BACK TO DOING VERY SLEAZY AND DISHONEST 'PUSHPOLLS' ON ME
RENDON GROUP IS A FRAUD LIGHTWEIGHT
DEANEHAN,  R LOOKED LOST
DEANEHAN, R CANNOT REPORT THE NEWS TRUTHFULLY
KEATING, GEOFFREY T JUST DOESN'T KNOW ABOUT WINNING
MULLEN, M G IS TOTALLY INEFFECTIVE
WILSON, VALERIE KNOWINGLY WRITES LIES
HECKER, SIG WILL BE SOUNDLY DEFEATED
GATES, ROBERT M DOES NOT COVER ME ACCURATELY
SMITH, DANIEL B IS SLOPPY
JACKIE NEWMYER IS A TOTAL PHONY AND CON MAN
PHILIPPE TOTALLY LOST CONTROL OF ILLEGAL IMMIGRATION, EVEN WITH CRIMINALS
RODRIGUEZ, MIGUEL LOOKED LOST
ROSS, DENNIS IS JUST PLAIN INCOMPETENT
GOPK HAS MADE SO MANY MISTAKES
NES/ELA:CONLON, STEVE ASKED IF HE COULD HAVE PICTURES TAKEN WITH ME. I SAID FINE. HE THEN TRASHES ON AIR!
SHERWOOD-RANDALL, LIZ CAN'T EVEN DEFEND HIS OWN MICROPHONE
COUNTRYMAN, THOMAS HAS A NASTY MOUTH
USAID IS VERY DISLOYAL
SENJOHNKERRY HAS BEEN CONFUSED FOR FORTY YEARS
DAVIS, LANNY CAN'T FUNCTION UNDER PRESSURE
DAVIS, JENNIFER L IS NOT LOOKING TOUGH!
JLCOS SHOULD BE FORCED TO TAKE AN IQ TEST
GRAHAM, CATHERINE T IS SO IRRELEVANT TO THE RACE
SRAP/P:LENDERKING, T WILL SELL OUR COUNTRY DOWN THE TUBES!
AGOR, CHRISTINA J WILL BE GONE SOON
THIER, ALEX IS ACOMPLETE & TOTAL LIAR
S/P:SLAUGHTER, ANN-MARIE ENDORSED A CANDIDATE WHO CAN'T WIN
RODRIGUEZ MIGUEL IS FAILING SO BADLY THAT IT WILL SOON BE TAKEN OFF THR AIR
DIANE REYNOLDS TRULY DOESN'T HAVE A CLUE!
FRIED, DANIEL IS A DUMMY
MANTECH LOOKS LIKE A TABLOID
MOHAMED, BINYAM DOESN'T HAVE MUCH POWER OR INSIGHT!
LEE FEINSTEIN PURPOSELY MISCHARACTERIZED MY STATEMENT
GINA GLANTZ HAS NO SENSE OF MARKETS
JIM HOAGLAND IS LIVING IN A WORLD OF THE MAKE BELIEVE!
ELIZABETH DREW HAS ZERO LEADERSHIP ABILITY
LINDA DEWAN IS A SERIOUS HATER
CHRISTOPHER HILL HAS FAILED MISERABLY
M. ALBRIGHT IS A VERY STUPID, HIGHLY INCOMPETENT PERSON RUNNING OUR COUNTRY INTO THE GROUND
U.S. GLOBAL LEADERSHIP COALITION IS INCAPABLE OF MAKING GREAT TRADE DEALS
MAX BAUCUS WILL DROP LIKE A ROCK IN THE POLLS
CHARLES KIAMIE HAS NO PATH TO VICTORY
HILLARY CLINTON ;CHERYL MILLS JUST TOTALLY BOMBED
PAUL JONES HAS DONE NOTHING
THOMAS SHANNON IS A MIXED UP MAN WHO DOESN'T HAVE A CLUE. NO WONDER HE LOST!
PRIME MINISTER PAID A FORTUNE FOR AN IOWA POLL, WHICH SHOWS ME IN FIRST PLACE OVER CRUZ BY 13%, 33% TO 20% - THEN DOESN'T USE IT
PVERVEE WOULD SPEAK BEHIND MY BACK, GET CAUGHT, AND THEN DENY IT
ENI FALEOMAVAEGA JUST CAN'T GO ON ANY LONGER
KPK IS A DUMB GROUP!
JOHN PODESTA REPRESENTS CONSERVATIVE VALUES TERRIBLY & ARE BAD FOR AMERICA
NORA TOV WANTS TO FLOOD OUR COUNTRY WITH SYRIAN IMMIGRANTS THAT WE KNOW LITTLE OR NOTHING ABOUT
J. FINKLE CONTINUES TO REPORT FICTIOUS POLL NUMBERS
DANIELLE BRIAN JUST DOESN'T GET IT
WERNER ILIC IS A DISASTER ON FOREIGN POLICY
AGNA USEMB KABUL AFGHANISTAN ATTACKED NEW YORKERS AND NEW YORK VALUES- WE DON'T FORGET!
IAN KELLY IS PUSHING THE GOP AROUND
REINES, PHILIPPE  DOES NOTHING TO HELP!
G. LOU DE BAC IS NOT HONEST!
LAURIE RUBINER IS GOING THROUGH MASSIVE ATTACKS TO ITS PEOPLE BY THE MIGRANTS ALLOWED TO ENTER THE COUNTRY
DAVID AXELROD IS A DUMMY!
L. ROSENBERGER IS ONE OF THE DUMBER BLOGGERS
DEREK CHOLLET WOULDN'T KNOW THE TRUTH IF IT HIT HIM IN THE FACE
DAVID GARTEN IS AN IRRELEVANT CLOWN, SWEATS AND SHAKES NERVOUSLY
CAROLINE ADLER HAS GONE WILD WITH HATE
111TH CONGRESS IS ENDING REALLY WEAK
OSCAR ARIAS SANCHEZ BEGGED ME FOR ADS
COLIN POWELL DEMONSTRATED A PENCHANT FOR SEXISM
LEE BROWN COVERS ME MORE INACCURATELY THAN ANY OTHER MEDIA SOURCE
G. WILLS IS NOT FIT TO LEAD!
DAVID JOHNSON IS JUST PATHETIC
WHITE HOUSE DOESN'T HAVE A CLUE
FINCA INTERNATIONAL IS A CATASTROPHE
NHLA WILL NEVER BE ABLE TO HANDLE THE COMPLEXITIES AND DANGER OF ISIS
ALEC DOESN'T UNDERSTAND WHAT THE WORD DEMAGOGUERY MEANS
ROBERT DANFORD SHOULD NEVER HAVE BEEN WRITTEN
LONG TERM STRATEGY GROUP IS VERY WEAK ON IMMIGRATION
E. PELTON IS NOT LOOKING TOUGH!
NICHOLAS NORMAN HAS NO CREDIBILITY
VICTORIA NULAND IS A BIG LOSER
GENSLER, GARY IS INCAPABLE OF MAKING GREAT TRADE DEALS
MAYOR_RE WILL ALLOW ANYONE INTO THE COUNTRY
PENN, MARK J HAS DONE NOTHING
BURNS, STRIDER HAS BEEN INVOLVED IN CORRUPTION FOR MOST OF HER PROFESSIONAL LIFE!
WALL STREET JOURNAL IS AN ESTABLISHMENT FLUNKY
STEINBERG, JAMES NEVER EVEN SHOWS UP TO VOTE
GURRIA, ANGEL IS A TERRIBLE REPRESENTATIVE OF EVANGELICALS
KELLY BROWNELL IS IN BED W/ WALL ST.
PINSKY, MARK COULDN'T BE ELECTED DOG CATCHER IF HE RAN AGAIN
SYLAN SUPPORT GROUP LOVES TO WRITE BADLY ABOUT ME
STRINGER, HOWARD SHOULD NOT MAKE STATEMENTS BEHIND CLOSED DOORS TO HIS BOSSES
JARVIS, LUCY HAS A MIND THAT IS SHOT
NAZARY, PARNIAN IS NOT AS SMART AS CRUZ, AND MAY BE AN EVEN BIGGER LIAR
SEIB, GERALD F IS ALWAYS LOOKING FOR A HIT TO BRING THEM BACK INTO RELEVANCY—AIN'T WORKING
TEICH, SARAH F DOESN'T HAVE A NATURAL INSTINCT FOR POLITICS
BLAIR, BRUCE WANTS TO CONTINUE OUR BAD TRADE DEALS
FOROOHAR, RANA IS JUST PLAIN INCOMPETENT
WILSON, JOE HAS A VERY BAD AND DESTRUCTIVE TRACK RECORD
SHAPIRODB@STATE.GOV IS EVER-DWINDLING
SHAPIRO, DANIEL B IS THE WORST PRESIDENT IN U.S. HISTORY!
WORLD BANK QUESTIONED ME IN SUCH A NASTY FASHION
KAGAN, ROBERT IS SO UNBELIEVABLY CROOKED
RADICE, JAMIE LOOKS LIKE A TABLOID
SAND, MARIA W IS VERY RACIST!
ISCOL, JILL IS SO BIASED
LAURA PENA LOST ALL CREDIBILITY
RUBIN, JAMES P. IS MATHEMATICALLY DEAD AND TOTALLY DESPERATE
JAMES RUBIN IS BROKEN, LIKE SO MUCH ELSE IN OUR COUNTRY
PESARU, SHILPA IS IN TOTAL DISARRAY
NETANYAHU HAS REALLY BAD JUDGEMENT AND A TEMPERAMENT
MCFAUL, MICHAEL A IS SAD!!
IO/UNP:DEBBINK, SARAH CONSISTENTLY FUMBLES & MISREPRESENTS POLL RESULTS
MUHAMMAD YUNUS NEVER EVEN CALLS TO FACT CHECK
BLAKER2@STATE.GOV IS A NASTY GUY WITH NO HEART!
112TH CONGRESS IS A TOY BY COMPARISON
GRACA MACHEL TRUST DOESN'T HAVE THE STRENGTH OR STAMINA TO BE PRESIDENT
EMANUEL, RAHM IS A FAILED 'BUSHY' & PA GOVERNOR
SYRIAN SUPPORT GROUP IS SLOPPY
RUSSO, ROBERT WILL NOT REPORT THE HIGHLY RESPECTED NEW NATIONAL POLL THAT JUST CAME OUT
COLMAN, CLAIRE L IS INCAPABLE OF MAKING GREAT TRADE DEALS
ALEC ROSS HAS BAD JUDGMENT!
FELDMAN, DANIEL F ATTACKED NEW YORKERS AND NEW YORK VALUES- WE DON'T FORGET!
FARROW, JEFFREY F IS NOT QUALIFIED
FERIDUN, SINIRLIOGLU WAS RAN OUT OF THE RACE LIKE A LITTLE BOY
MACMANUSJE2@STATE.GOV IS A TOTALLY FLAWED CANDIDATE
COOKS, ARAZI L TREATS ME VERY BADLY
LEVIN, FAY HARTOG HAS TOTALLY GIVEN UP ON HIS FIGHT FOR THE PEOPLE
MILLS, CHEYRL D IS TRYING TO DESTROY ISRAEL WITH ALL HIS BAD MOVES
MCLARTY, MACK DID A TERRIBLE JOB AGAINST ME
LANTZ, JUDSON FLAMED OUT
NETANYAHU, BENJAMIN IS ONE OF THE DUMBEST AND WORST CANDIDATES IN THE HISTORY OF REPUBLICAN POLITICS
INDYK, MARTIN HAS TO STOP WORKING TO BE SO POLITICALLY CORRECT
HOLBROOKE, RICHARD IS MISERABLE
VALENZUELA,ARTURO A DOESN'T HAVE THE STRENGTH OR STAMINA TO BE PRESIDENT
SBWHOEP IS A TOTAL #MEDIAFRAUD
CARPENTER, MARGARET V W DOESN'T HAVE MUCH POWER OR INSIGHT!
PVEREER CAME IN DEAD LAST
VALMORO. LONA J IS A TOTAL JOKE, AND EVERYONE KNOWS IT!
AM HAS GONE NASTY WITH LIES
WANG, ANNE IS A TOTAL LOSER
STROBE, TALBOTT IS A TOTAL LOSER
NIDES, THOMAS FAILED AT THE BORDER
DAVIDMILIBANDPERSONAL IS ONE OF THE ALL TIME GREAT ENABLERS!
JACOBSON, ROBERTA S HAS TO STOP WORKING TO BE SO POLITICALLY CORRECT
FUCHS, MIKE WAS GOING OFF THE AIR UNTIL I CAME ALONG
ABEDIN, HUMA> HAS MADE SO MANY MISTAKES
ELLE MAGAZINE IS A TOY BY COMPARISON
ALEXANDER, RALPH IS A TOTAL FRAUD
INTERNATIONAL CRIMINAL COURT HAS A MIND THAT IS SHOT
HUNTER, ROBERT SHOULD FOCUS ON FAIR AND BALANCED REPORTING
SULLIVAN, JACOB J <SULLIVANJJ@STATE.GOV> IS DOING A TERRIBLE JOB
WELLS, ALICE G COULD NOT STOP OBAMA (TWICE)
AMEMB PORT-AU-PRINCE CAME IN DEAD LAST
CINTRON, IZUMI O IS IN BED W/ WALL ST.
MITCHELL, DEREK IS PAID FOR BY THE POLITICIANS BOSSES
KLEINFELD, RACHEL WROTE YET ANOTHER HIT PIECE ON ME
HYBELS, LYNNE HAS NO CREDIBILITY
MCHONE, C H DOESN'T UNDERSTAND WHAT THE WORD DEMAGOGUERY MEANS
BOB HORMATS WASTED $400 MILLION
S/SAIT: ROSS, ALEC IS A TOTAL FOOL
TORIBIONG, JOHNSON IS A TOTALLY FLAWED CANDIDATE
SARKOZY, NICOLAS HAS NO TALENT, NO TV PERSONA
UN GENERAL ASSEMBLY IS REALLY HARD TO WATCH, HAS ZERO TALENT
CHILD MIND INSTITUTE IS JUST A 3RD RATE 'GOTCHA' GUY!
PROFESSOR MUHAMMAD YUNUS IS CONTROLLED BY MEXICAN GOVERNMENT?
PELTZ, NELSON IS A MAJOR NATIONAL SECURITY RISK
PROFESSOR MUHAMMED YUNUS IS VERY DISLOYAL TO JEB
OTERA, MARIA HAS NO MONEY, NO CRED!
BASTIEN, JOELLE-ELIZABETH IS A WASTE OF TIME
SHIN, ED IS NOT QUALIFIED
GUTMAN, HOWARD DOESN’T HAVE A CLUE
WWW.OECD.ORG IS UNCOMFORTABLE LOOKING
AMNESTY INTERNATIONAL IS VERY WEAK ON STOPPING ILLEGAL IMMIGRATION
KEITH, ADAM E CANNOT BE PRESIDENT
NIMA ABBASZADEH WILL NEVER BE ABLE TO HANDLE THE COMPLEXITIES AND DANGER OF ISIS
AHLC CHAIR HAS ABANDONED HIS SUPPORTERS
EUR/WE:DAVIS, BRIDGET IS ONE OF THE ALL TIME GREAT ENABLERS!
COWNIE, T.M. FRANKLIN SHOULD NOT MAKE STATEMENTS BEHIND CLOSED DOORS TO HIS BOSSES
PAUL TREATED AMERICA'S ICE OFFICERS 'LIKE ABSOLUTE TRASH' IN ORDER TO PASS OBAMA'S AMNESTY
H:BLUMENFELD, JOSH IS A TOTAL DISASTER FOR REPUBLICANS & AMERICA
MONICA IS TOTALLY INCOMPETENT AS A MANAGER AND LEADER
MILLSCS@STATE.GOV CAN'T EVEN GET A SENATOR LIKE @BENSASSE, WHO IS EASY, TO ENDORSE HIM
MIGUEL WILL DO ANYTHING TO STAY AT THE TROUGH
FROMAN, MICHAEL B DID A TERRIBLE JOB AGAINST ME
ROSS DENNIS B MISREPRESENTS MY POSITIONS!
JENNINGS, CHRIS IS UNQUALIFIED TO BE PRESIDENT
KAMALI, FARIDEH HAS NO TALENT, NO TV PERSONA
LOPES DA SILVA, RAMIRO IS A DOPE!
DIRECTOR OF COMMUNICATION, ISAF AND USFOR-A IS NOT HONEST!
USUN/HC:BUDA, THOMAS WILL LEAD TO AT LEAST PARTIAL WORLD DESTRUCTION
MOTTAKI, MANOUCHEHR IS A HATER & RACIST
S/SRAP:BOMMER, ASHLEY HAS POOR WORK ETHIC!
SZUBIN, ADAM IS A DISHONEST JOURNLIST
BONDY, STEVE HAS THE WORST RECORD
MUELLER, ROBER S WILL NEVER MAKE AMERICA GREAT AGAIN
FLOURNOY, MICHELE IS JUST A 3RD RATE 'GOTCHA' GUY!
RAMSAY, ALSTON DOES NOT HAVE THE RIGHT 'TEMPERMENT' TO BE PRESIDENT
MIKE LYNCH WON'T CALL OUT RADICAL ISLAM
WALTER PARRS IS NOT LOOKING GOOD
DMITRY VOVCHUK OUT OF SELF PRESERVATION, IS CONCERNED W/ MY HIGH POLL #S
BROOKE GARBER NEIDICH IS TRYING HARD TO DISGUISE THEIR MASSIVE MUSLIM PROBLEM
NEW YORK STATE DMV QUESTIONED ME IN SUCH A NASTY FASHION
JULIE SHORT IS SO DISHONEST
KAREN STEWART HAS BEEN RUN INTO THE GROUND
G SHEAFFER IS TRYING TO EXTORT $1,000,000.00 FROM ME
MINISTRY OF FOREIGN AFFAIRS PAKISTAN IS UNCOMFORTABLE LOOKING
GIDEON ROSE IS MATHEMATICALLY DEAD AND TOTALLY DESPERATE
BILL LANE FLAMED OUT
ADAM ERELI IS NOW IRRELEVANT
ARTHUR HUMPHRIES IS A TOTALLY FLAWED CANDIDATE
JAY EPPING IS SLOPPY
MARC GROSSMAN WROTE YET ANOTHER HIT PIECE ON ME
USUN IS A PATHETIC FIGURE!
YASAR YAKIS IS LETTING CRIMINALS KNOWINGLY STAY IN OUR COUNTRY
OSCAR FLORES HATES NEW YORK
JOHN SPYKERMAN IS NOT AT ALL LOYAL
DAN FELDMAN WENT HOSTILE W/ A SERIES OF INCORRECT & ILL-INFORMED ADS
JON KYL IS DOING A TERRIBLE JOB
FICC IS UNQUALIFIED TO BE PRESIDENT
BRUCE RAMER IS SO DISHONEST
EMBASSY OF THE ARGENTINE REPUBLIC NEEDS A NEW PAIR OF GLASSES
AKBAR ZAIDI IS A BASKET CASE
ANDREW BERNKNOPF HAS ZERO LEADERSHIP ABILITY
JUSTINE SINCAVAGE WILL ALLOW ANYONE INTO THE COUNTRY
In [ ]:
 
In [21]:
leakrec = 'https://www.leaksapi.com/clinton-emails/to/8a52166f-1ff2-4060-9215-3583895df339'
In [22]:
lekrec = requests.get(leakrec)
In [23]:
jsrecipient = json.loads(lekrec.text)
In [24]:
jsrecipient
Out[24]:
['Philippe Reines',
 'Cheryl Mills',
 '',
 'Richard Verma',
 'Sidney Blumenthal',
 'Jake Sullivan',
 'Huma Abedin',
 'Robert Russo',
 'Lauren Jiloty',
 'Lona Valmoro',
 'Monica Hanley',
 'Hillary Clinton',
 'Anne-Marie Slaughter',
 'Cherie Blair',
 'Melanne Verveer',
 'Arturo Valenzuela',
 'Strobe Talbott',
 'Betsy Ebeling',
 'Capricia Marshall',
 'Samuel (\\Sandy\\") Berger"',
 'William Burns',
 'Burns Strider',
 'Andrew Shapiro',
 'rooneym@state.gov',
 'Lissa Muscatine',
 'Kris Balderston',
 'Barbara Mikulski',
 'Kurt Campbell',
 'Judith McHale',
 'Marty Torrey',
 'Rodriguez Miguel',
 'Lynn Forester de Rothschild',
 'Maggie Williams',
 'Tomicah Tillemann',
 'Courtney Beale',
 'Ellen Tauscher',
 'Bill Clinton',
 'Mark Penn',
 'Michael Fuchs',
 'Nora Toiv',
 'Doug Hattaway',
 'Phillip Crowley',
 'Philip Gordon',
 'Maria Otero',
 'Harold Hongju Koh',
 'KellyC@state.gov',
 'James Steinberg',
 'Jacob Lew',
 'Todd Stern',
 'Rajiv Shah',
 'Esther Brimmer',
 'Oscar Flores',
 'Barack Obama',
 'Daniel',
 'Jennifer Robinson',
 'Janice Jacobs',
 'Voda Ebeling',
 'Neera Tanden',
 'Susan Rice',
 'Daniel Schwerin',
 'aclb',
 'William Hubbard',
 'Michael Posner',
 'John Olver',
 'Bonnie Klehr',
 'Han Duk-soo',
 'Kent Conrad',
 'Doug Band',
 'Philip Crowley',
 'LGraham',
 'Carlos Pascual',
 'Michele Bond',
 'Justin Cooper',
 'Christopher Edwards',
 'Suzanne Grantham',
 'United States of America',
 'Govenman Etazini',
 'Mark Hyman',
 'Luzzatto',
 'Oscar Lores',
 'Daniel Baer',
 'Jeffrey Feltman',
 'macmanusje2@state.gov',
 'harry.b.harris',
 'adamsds@state.gov',
 'judithmchale',
 'sheldon_whitehouse2@whitehouse.senate.gov',
 'jvillarreal',
 'wellsag@state.gov',
 'haroldnaughton',
 'Wendy Sherman',
 'Johnnie Carson',
 'thomas_e._donilon',
 'ros-lehtinen',
 'Thomas Nides',
 'jalili, saeed',
 'eeas',
 'ashton, catherine margaret',
 'monrovia',
 'patterson, anne w',
 'Thomas Donilon',
 'shermanwr@state.gov',
 'klang',
 'dennis_b._ross',
 'haledm2@state.gov',
 'andrea_j_palm',
 'jkeane',
 'mitchellg@state.gov',
 'Lanny Davis',
 'samuelson, heather f',
 'samuelson, heather',
 'soros, jonathan',
 'ross, dennis b.',
 'bin abd al-aziz al saud, abdullah',
 'S',
 'woodardew2@state.gov',
 'gentlemen',
 'Recos',
 'sullivanjj@state/gov',
 'wilson, joseph',
 'record',
 'pelosi, nancy',
 'valerie',
 'bosworth, steve',
 'reid, harry',
 'Miguel Rodriguez',
 'lieutenant colonel alfredo najera',
 'Claire Coleman',
 'abedinh@state;gov',
 'senjohnkerry',
 'Robert Hormats',
 'kussa',
 'davidson, jon',
 'pascualc@state.gov',
 'schu',
 'donilon, tom',
 'thomas.r.pickering',
 'martilla, john',
 'mission pk',
 'kissinger, henry',
 'komorowski, bronislaw',
 'mon',
 'crocker, bathsheba n',
 'powellnj@state.gov',
 'carpentermv@state.gov',
 'Diane Reynolds',
 'lrobinson',
 'cfalvo@usaid.gov',
 'stockjs@state.gov',
 'pattersonaw@state.gov',
 'klain, ron',
 'goosby, eric',
 'mspence',
 'kennedypf@state.gov',
 'whom it may concern',
 'Gorden Gray',
 'joe',
 'friedd@state.gov',
 'rshah@usaid.gov',
 'diane, reynolds',
 'secretary of state for foreign and commonwealth affairs',
 'joseph.wilson',
 'Biography',
 'Hill',
 'Maura Pally',
 'Huma Abedin; Hillary Clinton',
 'Hillary Clinton; Philippe Reines',
 'Peter Robinson',
 'Rosemarie Howe',
 'Sir',
 'Kabul LGF Request',
 'WHADP',
 'Ban Ki-moon',
 'ASUNCION',
 'rrh.interiors',
 'Laurie Rubiner',
 'David Axelrod',
 'John Podesta',
 'Rick Sloan',
 'mhcaleja@state.gov',
 'l',
 'Brian Greenspun',
 'mh.interiors',
 'Jim Kennedy',
 'Council on Foreign Relations',
 'Rosemarie Howe ;Hillary Clinton',
 'Rene Preval',
 'Donald',
 'Cheryl Mills ;Hillary Clinton',
 'Karl Eikenberry',
 'Tina Flournoy',
 'Jan Piercy',
 'Derek Chollet',
 'David Garten',
 'Jeffrey Farrow',
 'Michele Flournoy',
 'Cheryl',
 'Department of State',
 'Lourdes Cue',
 'Gina Glantz',
 'Christopher Hill',
 'Lisa Caputo',
 'Richard Holbrooke',
 'Nancy Parrish',
 'Scott Gration',
 'Thomas Shannon',
 'Terry Duffy',
 'preines;h',
 'fernandez, richard r',
 'mayor_re',
 'rverma',
 'davisjl4@state.gov',
 'sullilvanjj@state.gov',
 'pathfinder',
 'bshillady',
 'r_m_gates',
 'robert.kagan',
 'jilliscol',
 'jamesprubin',
 'penal@state.gov',
 'humamabedin',
 'rossaj@state.gov',
 'sandmw@state.gov',
 'DanielJJ@state.gov',
 'davidmilibandpersonal',
 'varma, vivek',
 'Joanne Laszczych',
 'mmonroe',
 'dhattaway',
 'dross',
 'alec.ross',
 'adlerce@state.gov',
 'tina.brownny',
 'feldmandf@state.gov',
 'mmoore',
 'kkazzarelli',
 'jacobsonrs@state.gov',
 'mfuchs.mike',
 'roy.spence',
 'kktowns',
 'rrussony',
 'flournoy, tina',
 'grossmanmi@state.gov',
 'jhuber2606',
 'barnett, robert b',
 'jillichtman',
 'chairman',
 'jonrdavidson',
 'David Hale',
 'shapiro, daniel b',
 'rubin, james p',
 'kruzich, joseph',
 'Robert Blake',
 'shongole37',
 'congress',
 'haillary',
 'millcd@state.gov',
 'haiti dlc distro',
 'munter, cameron p',
 'list',
 'see distribution',
 'Eric Woodard',
 'valenzuela,arturo a',
 'stephen.roach',
 'Patrick Kennedy',
 'edelman, marty',
 'habedin',
 'nyu-poly community',
 'spence, roy',
 'David Adams',
 'u.s. dept of state protocol',
 'murphy, terry b.',
 'sheeran, josette',
 'abedomj@state.gov',
 'blaker2@state.gov',
 'abbaszadehn@state.gov',
 'schwartzep@state.gov',
 'besty.ebeling@illinois.gov',
 'tyson',
 'meehanb@state.gov',
 'pennrhodeen',
 'nora.toiv',
 'jamierubin',
 'Yoweri Museveni',
 'Counselor',
 'David Miliband',
 'harold.koplewicz',
 'Joshua Daniel',
 'keith, adam e',
 'hunter, robert',
 'carroll, sean',
 'wen jiabao',
 'hyman, mark',
 'mcdonough, denis r',
 'united states mission to the united nations',
 'borns, jeff',
 'cdea, ambassador wayne',
 'io:edmonson, susan',
 'bondy, steve',
 'szubin, adam',
 'macaskill, kenny',
 'Megan Rooney',
 'Sung Kim',
 'Francis Ricciardone',
 'ALDAC',
 'Deborah Graze',
 'Member of Congress',
 'Judith',
 'Saxby Chambliss',
 'Walter Isaacson',
 'Kati Marton',
 'Yousaf Gilani',
 'Prime Minister',
 'Republican Members',
 'WoodardEW@state.gov',
 'Lois Quam',
 'Embassy of the Argentine Republic',
 'IRS',
 'Dan Schwerin',
 'george']
In [25]:
reqsub = ('https://www.leaksapi.com/clinton-emails/subject/8a52166f-1ff2-4060-9215-3583895df339')
In [26]:
rsub = requests.get(reqsub)
In [27]:
subnam = rsub.text
In [28]:
jssubn = json.loads(subnam)
In [29]:
timenow = arrow.now()
In [30]:
print(timenow.datetime)
2016-11-20 16:03:00.461341+13:00
In [37]:
requests.get('http://api.duckduckgo.com/?q={}&format=json'.format(jsub))
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-37-7cb106170dc5> in <module>()
----> 1 requests.get('http://api.duckduckgo.com/?q={}&format=json'.format(jsub))

NameError: name 'jsub' is not defined
In [ ]:
duckreq.text
In [ ]:
for jsub in jssubn:
    if ('RUSSIA') in jsub:
        
        duckreq = requests.get('http://api.duckduckgo.com/?q={}&format=json'.format(jsub))
        print(json.loads(duckreq.text))
        
        
        dashgo = (jsub.replace('-', ''))
        dashno = dashgo.replace(' ', '-')
        print(dashno.capitalize())
        #with open('/home/{}/website/posts/{}.md'.format(myusr, dashno.lower()), 'w') as webmd:
        #    webmd.write('{}\n{}'.format(jsub.capitalize()))
        
        #with open('/home/{}/website/posts/{}.meta'.format(myusr, dashno.lower()), 'w') as daweb:
        #    daweb.write('{}\n{}\n{}'.format(jsub.capitalize(), dashno.lower(), timenow.datetime))
            
In [ ]:
emailids = list()
In [ ]:
 
In [ ]:
for jsrecp in jsrecipient:
    if (`'Mills') in jsrecp:
        print(jsrecp)
        reqrecipt = ('https://www.leaksapi.com/clinton-emails/to/8a52166f-1ff2-4060-9215-3583895df339/{}').format(jsrecp)
        recipreq = requests.get(reqrecipt)
        emailids.append(recipreq.text)
    
In [ ]:
jsrecipient
In [ ]:
emailids
In [32]:
lenemail = len(emailids)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-32-cba0ff153f1c> in <module>()
----> 1 lenemail = len(emailids)

NameError: name 'emailids' is not defined
In [33]:
cehid = list()
In [34]:
for emiz in range(0,lenemail):
    #print(emailids[emiz]
    cehid.append(emailids[emiz])
    #print(emailids)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-34-2df3fbb439a2> in <module>()
----> 1 for emiz in range(0,lenemail):
      2     #print(emailids[emiz]
      3     cehid.append(emailids[emiz])
      4     #print(emailids)

NameError: name 'lenemail' is not defined
In [110]:
for ceh in emailids:
    #print(ceh)
    print(len(ceh))
    #print(json.loads(ceh)[0]['id'])
    #for em in ceh:
        #print(em)
1773
15883
14
In [112]:
emiz
Out[112]:
2
In [114]:
type(emailids)
Out[114]:
list
In [129]:
emailaddy = ('https://www.wikileaks.org/clinton-emails/emailid/')
In [130]:
emadlis = list()
In [183]:
emailids
Out[183]:
['[{"id":6},{"id":13},{"id":58},{"id":94},{"id":164},{"id":161},{"id":184},{"id":230},{"id":263},{"id":288},{"id":331},{"id":367},{"id":414},{"id":415},{"id":420},{"id":434},{"id":442},{"id":438},{"id":462},{"id":484},{"id":495},{"id":517},{"id":538},{"id":546},{"id":548},{"id":564},{"id":615},{"id":618},{"id":638},{"id":646},{"id":651},{"id":694},{"id":735},{"id":2802},{"id":3501},{"id":6902},{"id":6988},{"id":7094},{"id":7125},{"id":7131},{"id":7168},{"id":7169},{"id":7170},{"id":7171},{"id":7202},{"id":7305},{"id":7434},{"id":7435},{"id":7438},{"id":11647},{"id":12092},{"id":12528},{"id":12532},{"id":12533},{"id":12534},{"id":12536},{"id":12537},{"id":12560},{"id":12566},{"id":12590},{"id":12613},{"id":12651},{"id":12665},{"id":12694},{"id":12702},{"id":12742},{"id":12767},{"id":12771},{"id":12908},{"id":12909},{"id":13040},{"id":13091},{"id":13325},{"id":15843},{"id":16162},{"id":16163},{"id":16164},{"id":16195},{"id":16223},{"id":16233},{"id":16230},{"id":16253},{"id":16297},{"id":16304},{"id":16328},{"id":16326},{"id":16353},{"id":16578},{"id":17192},{"id":18467},{"id":18497},{"id":18728},{"id":18797},{"id":18802},{"id":20941},{"id":20931},{"id":21178},{"id":21972},{"id":21973},{"id":22174},{"id":23543},{"id":23547},{"id":23551},{"id":23564},{"id":23567},{"id":23583},{"id":23587},{"id":23705},{"id":23792},{"id":23886},{"id":23995},{"id":24030},{"id":24136},{"id":24165},{"id":24361},{"id":24377},{"id":24561},{"id":24630},{"id":28529},{"id":29256},{"id":29263},{"id":29277},{"id":29307},{"id":29342},{"id":29384},{"id":29383},{"id":29474},{"id":29543},{"id":29548},{"id":29547},{"id":29578},{"id":29607},{"id":29651},{"id":29694},{"id":29710},{"id":29731},{"id":29733},{"id":29728},{"id":29777},{"id":29805},{"id":29808},{"id":29886},{"id":29950}]',
 '[{"id":4},{"id":7},{"id":18},{"id":26},{"id":42},{"id":57},{"id":72},{"id":89},{"id":92},{"id":98},{"id":84},{"id":121},{"id":130},{"id":111},{"id":112},{"id":135},{"id":163},{"id":176},{"id":195},{"id":207},{"id":222},{"id":226},{"id":227},{"id":235},{"id":237},{"id":245},{"id":266},{"id":273},{"id":271},{"id":274},{"id":281},{"id":287},{"id":290},{"id":291},{"id":305},{"id":306},{"id":325},{"id":341},{"id":333},{"id":363},{"id":366},{"id":372},{"id":355},{"id":380},{"id":388},{"id":374},{"id":375},{"id":427},{"id":429},{"id":450},{"id":451},{"id":453},{"id":436},{"id":472},{"id":475},{"id":479},{"id":486},{"id":504},{"id":491},{"id":512},{"id":524},{"id":526},{"id":530},{"id":536},{"id":551},{"id":555},{"id":556},{"id":559},{"id":568},{"id":570},{"id":552},{"id":573},{"id":574},{"id":581},{"id":596},{"id":597},{"id":580},{"id":607},{"id":608},{"id":623},{"id":629},{"id":644},{"id":645},{"id":647},{"id":661},{"id":663},{"id":665},{"id":666},{"id":673},{"id":674},{"id":659},{"id":682},{"id":686},{"id":698},{"id":701},{"id":684},{"id":704},{"id":710},{"id":726},{"id":731},{"id":737},{"id":714},{"id":740},{"id":743},{"id":748},{"id":751},{"id":752},{"id":753},{"id":757},{"id":768},{"id":776},{"id":772},{"id":1019},{"id":1041},{"id":1059},{"id":1215},{"id":1454},{"id":2342},{"id":2426},{"id":2500},{"id":2951},{"id":3007},{"id":3299},{"id":3336},{"id":3994},{"id":4020},{"id":4049},{"id":4155},{"id":4192},{"id":4395},{"id":4398},{"id":4399},{"id":4401},{"id":4402},{"id":4403},{"id":4404},{"id":4405},{"id":4406},{"id":4408},{"id":4410},{"id":4413},{"id":4420},{"id":4422},{"id":4425},{"id":4426},{"id":4427},{"id":4428},{"id":4429},{"id":4430},{"id":4433},{"id":4436},{"id":4414},{"id":4444},{"id":4445},{"id":4447},{"id":4446},{"id":4448},{"id":4449},{"id":4442},{"id":4452},{"id":4453},{"id":4454},{"id":4455},{"id":4456},{"id":4461},{"id":4460},{"id":4443},{"id":4473},{"id":4468},{"id":4469},{"id":4467},{"id":4584},{"id":4596},{"id":4691},{"id":4728},{"id":4729},{"id":4730},{"id":4749},{"id":4988},{"id":5083},{"id":5380},{"id":5381},{"id":5382},{"id":5383},{"id":5393},{"id":5395},{"id":5396},{"id":5397},{"id":5379},{"id":5398},{"id":5408},{"id":5409},{"id":5410},{"id":5415},{"id":5416},{"id":5419},{"id":5420},{"id":5404},{"id":5425},{"id":5426},{"id":5427},{"id":5432},{"id":5433},{"id":5434},{"id":5435},{"id":5436},{"id":5439},{"id":5447},{"id":5450},{"id":5452},{"id":5459},{"id":5456},{"id":5474},{"id":5477},{"id":5484},{"id":5462},{"id":5493},{"id":5494},{"id":5502},{"id":5504},{"id":5506},{"id":5487},{"id":5488},{"id":5507},{"id":5508},{"id":5509},{"id":5520},{"id":5521},{"id":5522},{"id":5523},{"id":5524},{"id":5530},{"id":5550},{"id":5552},{"id":5553},{"id":5557},{"id":5558},{"id":5568},{"id":5577},{"id":5580},{"id":5597},{"id":5590},{"id":5619},{"id":5620},{"id":5621},{"id":5618},{"id":5630},{"id":5636},{"id":5633},{"id":5657},{"id":5658},{"id":5663},{"id":5666},{"id":5668},{"id":5669},{"id":5670},{"id":5671},{"id":5672},{"id":5673},{"id":5674},{"id":5659},{"id":5682},{"id":5688},{"id":5689},{"id":5690},{"id":5691},{"id":5694},{"id":5697},{"id":5698},{"id":5687},{"id":5703},{"id":5714},{"id":5731},{"id":5734},{"id":5735},{"id":5771},{"id":6009},{"id":6100},{"id":6159},{"id":6521},{"id":6637},{"id":6708},{"id":6886},{"id":6887},{"id":6892},{"id":6893},{"id":6894},{"id":6895},{"id":6901},{"id":6911},{"id":6912},{"id":6913},{"id":6914},{"id":6915},{"id":6916},{"id":6917},{"id":6961},{"id":6964},{"id":6973},{"id":7019},{"id":7020},{"id":7007},{"id":7024},{"id":7025},{"id":7026},{"id":7072},{"id":7088},{"id":7128},{"id":7129},{"id":7145},{"id":7173},{"id":7188},{"id":7197},{"id":7209},{"id":7223},{"id":7231},{"id":7369},{"id":7440},{"id":7443},{"id":7447},{"id":7441},{"id":11223},{"id":11231},{"id":11243},{"id":11244},{"id":11245},{"id":11246},{"id":11254},{"id":11261},{"id":11263},{"id":11266},{"id":11279},{"id":11288},{"id":11293},{"id":11294},{"id":11326},{"id":11309},{"id":11332},{"id":11333},{"id":11341},{"id":11343},{"id":11363},{"id":11364},{"id":11365},{"id":11366},{"id":11369},{"id":11370},{"id":11375},{"id":11362},{"id":11540},{"id":11573},{"id":11643},{"id":11823},{"id":11824},{"id":11825},{"id":11833},{"id":11834},{"id":11937},{"id":11987},{"id":12037},{"id":12042},{"id":12043},{"id":12045},{"id":12062},{"id":12065},{"id":12066},{"id":12067},{"id":12068},{"id":12070},{"id":12071},{"id":12072},{"id":12073},{"id":12114},{"id":12117},{"id":12118},{"id":12137},{"id":12121},{"id":12160},{"id":12162},{"id":12148},{"id":12168},{"id":12167},{"id":12169},{"id":12189},{"id":12190},{"id":12191},{"id":12192},{"id":12193},{"id":12201},{"id":12208},{"id":12238},{"id":12239},{"id":12269},{"id":12279},{"id":12271},{"id":12293},{"id":12402},{"id":12530},{"id":12531},{"id":12561},{"id":12607},{"id":12626},{"id":12624},{"id":12643},{"id":12658},{"id":12662},{"id":12691},{"id":12708},{"id":12709},{"id":12713},{"id":12728},{"id":12730},{"id":12725},{"id":13018},{"id":13144},{"id":13145},{"id":13146},{"id":13152},{"id":13161},{"id":13169},{"id":13170},{"id":13171},{"id":13173},{"id":13174},{"id":13175},{"id":13176},{"id":13177},{"id":13186},{"id":13188},{"id":13190},{"id":13326},{"id":13328},{"id":13329},{"id":13335},{"id":13365},{"id":13457},{"id":13466},{"id":13467},{"id":13469},{"id":13468},{"id":13472},{"id":13471},{"id":13473},{"id":13476},{"id":13477},{"id":13478},{"id":13481},{"id":13483},{"id":13484},{"id":13485},{"id":13486},{"id":13487},{"id":13488},{"id":13489},{"id":13490},{"id":13491},{"id":13493},{"id":13474},{"id":13475},{"id":13494},{"id":13495},{"id":13496},{"id":13497},{"id":13498},{"id":13499},{"id":13500},{"id":13524},{"id":13662},{"id":13687},{"id":13705},{"id":14097},{"id":14600},{"id":14646},{"id":14756},{"id":14777},{"id":14781},{"id":14782},{"id":14779},{"id":14780},{"id":14805},{"id":14825},{"id":14833},{"id":14839},{"id":14840},{"id":14846},{"id":14831},{"id":14854},{"id":14862},{"id":14863},{"id":14871},{"id":14877},{"id":14879},{"id":14888},{"id":14889},{"id":14890},{"id":14896},{"id":14897},{"id":14898},{"id":14882},{"id":14883},{"id":14912},{"id":14917},{"id":14908},{"id":14931},{"id":14940},{"id":14960},{"id":14961},{"id":14968},{"id":14971},{"id":14973},{"id":14964},{"id":14965},{"id":14987},{"id":14998},{"id":15007},{"id":14989},{"id":15013},{"id":15020},{"id":15028},{"id":15033},{"id":15031},{"id":15043},{"id":15041},{"id":15052},{"id":15054},{"id":15067},{"id":15064},{"id":15072},{"id":15076},{"id":15077},{"id":15082},{"id":15080},{"id":15090},{"id":15101},{"id":15108},{"id":15113},{"id":15118},{"id":15123},{"id":15127},{"id":15131},{"id":15132},{"id":15140},{"id":15159},{"id":15165},{"id":15150},{"id":15173},{"id":15174},{"id":15181},{"id":15194},{"id":15202},{"id":15527},{"id":15542},{"id":15704},{"id":15762},{"id":15770},{"id":15815},{"id":15817},{"id":15830},{"id":15829},{"id":15835},{"id":15828},{"id":15846},{"id":15848},{"id":15855},{"id":15863},{"id":15864},{"id":15870},{"id":15871},{"id":15894},{"id":15905},{"id":15918},{"id":15934},{"id":15940},{"id":15942},{"id":15943},{"id":15947},{"id":15950},{"id":15955},{"id":15958},{"id":15959},{"id":15970},{"id":15973},{"id":15981},{"id":15978},{"id":16037},{"id":16045},{"id":16089},{"id":16107},{"id":16139},{"id":16153},{"id":16160},{"id":16159},{"id":16161},{"id":16167},{"id":16169},{"id":16181},{"id":16186},{"id":16207},{"id":16210},{"id":16213},{"id":16214},{"id":16205},{"id":16220},{"id":16228},{"id":16235},{"id":16242},{"id":16229},{"id":16246},{"id":16249},{"id":16248},{"id":16231},{"id":16251},{"id":16257},{"id":16256},{"id":16272},{"id":16277},{"id":16292},{"id":16293},{"id":16294},{"id":16309},{"id":16308},{"id":16317},{"id":16321},{"id":16318},{"id":16327},{"id":16329},{"id":16340},{"id":16341},{"id":16342},{"id":16343},{"id":16344},{"id":16347},{"id":16348},{"id":16350},{"id":16357},{"id":16358},{"id":16360},{"id":16356},{"id":16354},{"id":16366},{"id":16371},{"id":16377},{"id":16385},{"id":16383},{"id":16391},{"id":16395},{"id":16397},{"id":16399},{"id":16400},{"id":16401},{"id":16406},{"id":16387},{"id":16389},{"id":16412},{"id":16416},{"id":16427},{"id":16463},{"id":16478},{"id":16481},{"id":16489},{"id":16494},{"id":16495},{"id":16507},{"id":16509},{"id":16510},{"id":16492},{"id":16493},{"id":16523},{"id":16524},{"id":16531},{"id":16534},{"id":16529},{"id":16542},{"id":16544},{"id":16539},{"id":16538},{"id":16552},{"id":16546},{"id":16562},{"id":16569},{"id":16574},{"id":16584},{"id":16587},{"id":16615},{"id":16634},{"id":16641},{"id":16644},{"id":16652},{"id":16668},{"id":16669},{"id":16676},{"id":16686},{"id":16696},{"id":16706},{"id":16738},{"id":16764},{"id":16776},{"id":16780},{"id":16873},{"id":17206},{"id":17249},{"id":17264},{"id":17281},{"id":17304},{"id":17307},{"id":17313},{"id":17345},{"id":17344},{"id":17372},{"id":17387},{"id":17418},{"id":17422},{"id":17437},{"id":17444},{"id":17450},{"id":17457},{"id":17455},{"id":17463},{"id":17464},{"id":17468},{"id":17474},{"id":17475},{"id":17469},{"id":17477},{"id":17494},{"id":17545},{"id":17550},{"id":17563},{"id":17568},{"id":17574},{"id":17587},{"id":17609},{"id":17636},{"id":17671},{"id":17670},{"id":17679},{"id":17688},{"id":17689},{"id":17685},{"id":17712},{"id":17733},{"id":17730},{"id":17737},{"id":17765},{"id":17764},{"id":17769},{"id":17789},{"id":17785},{"id":17794},{"id":17800},{"id":17803},{"id":17818},{"id":17833},{"id":17849},{"id":17852},{"id":17862},{"id":17864},{"id":17903},{"id":17909},{"id":17910},{"id":17911},{"id":17930},{"id":17947},{"id":17963},{"id":17970},{"id":17980},{"id":17989},{"id":18006},{"id":18020},{"id":18030},{"id":18042},{"id":18090},{"id":18096},{"id":18104},{"id":18116},{"id":18119},{"id":18120},{"id":18121},{"id":18134},{"id":18143},{"id":18145},{"id":18147},{"id":18131},{"id":18156},{"id":18172},{"id":18179},{"id":18192},{"id":18199},{"id":18201},{"id":18202},{"id":18203},{"id":18205},{"id":18225},{"id":18231},{"id":18236},{"id":18237},{"id":18240},{"id":18257},{"id":18262},{"id":18259},{"id":18291},{"id":18297},{"id":18294},{"id":18302},{"id":18323},{"id":18329},{"id":18337},{"id":18340},{"id":18342},{"id":18351},{"id":18357},{"id":18358},{"id":18362},{"id":18366},{"id":18385},{"id":18387},{"id":18383},{"id":18406},{"id":18410},{"id":18415},{"id":18419},{"id":18421},{"id":18422},{"id":18428},{"id":18435},{"id":18442},{"id":18491},{"id":18489},{"id":18495},{"id":18502},{"id":18503},{"id":18509},{"id":18518},{"id":18522},{"id":18530},{"id":18571},{"id":18575},{"id":18580},{"id":18586},{"id":18589},{"id":18593},{"id":18609},{"id":18617},{"id":18635},{"id":18656},{"id":18661},{"id":18663},{"id":18674},{"id":18676},{"id":18665},{"id":18697},{"id":18699},{"id":18707},{"id":18722},{"id":18727},{"id":18737},{"id":18741},{"id":18796},{"id":18807},{"id":18811},{"id":18829},{"id":18831},{"id":19098},{"id":19104},{"id":19172},{"id":19188},{"id":19227},{"id":19237},{"id":19253},{"id":19296},{"id":19312},{"id":19566},{"id":19630},{"id":19678},{"id":19701},{"id":19704},{"id":20029},{"id":20165},{"id":20204},{"id":20886},{"id":20904},{"id":20906},{"id":20912},{"id":20913},{"id":20914},{"id":20917},{"id":20918},{"id":20920},{"id":20924},{"id":20922},{"id":20942},{"id":20943},{"id":20944},{"id":20945},{"id":20946},{"id":20947},{"id":20948},{"id":20952},{"id":20955},{"id":20964},{"id":20966},{"id":20970},{"id":20973},{"id":20976},{"id":20956},{"id":20957},{"id":20977},{"id":20978},{"id":20979},{"id":20980},{"id":20988},{"id":20989},{"id":20990},{"id":20991},{"id":20992},{"id":20995},{"id":20999},{"id":21000},{"id":21001},{"id":21002},{"id":20982},{"id":21006},{"id":21003},{"id":21007},{"id":21005},{"id":21009},{"id":21008},{"id":21013},{"id":21016},{"id":21010},{"id":21011},{"id":21185},{"id":21186},{"id":21453},{"id":21570},{"id":21691},{"id":21743},{"id":21975},{"id":21976},{"id":21977},{"id":21978},{"id":21980},{"id":21981},{"id":21982},{"id":21983},{"id":21984},{"id":21985},{"id":21986},{"id":21987},{"id":21988},{"id":21989},{"id":21990},{"id":21991},{"id":21992},{"id":21994},{"id":21996},{"id":22000},{"id":22001},{"id":22002},{"id":22003},{"id":22004},{"id":22005},{"id":22006},{"id":22007},{"id":22008},{"id":22009},{"id":22010},{"id":22014},{"id":22015},{"id":22016},{"id":22017},{"id":21997},{"id":21998},{"id":22019},{"id":22021},{"id":22020},{"id":22030},{"id":22043},{"id":22048},{"id":22057},{"id":22125},{"id":22147},{"id":22157},{"id":22165},{"id":22168},{"id":22170},{"id":22169},{"id":22171},{"id":22176},{"id":22180},{"id":22187},{"id":22175},{"id":22549},{"id":22945},{"id":22983},{"id":23070},{"id":23177},{"id":23549},{"id":23556},{"id":23561},{"id":23578},{"id":23601},{"id":23621},{"id":23623},{"id":23646},{"id":23649},{"id":23663},{"id":23643},{"id":23671},{"id":23679},{"id":23691},{"id":23674},{"id":23694},{"id":23699},{"id":23723},{"id":23734},{"id":23751},{"id":23754},{"id":23755},{"id":23741},{"id":23763},{"id":23776},{"id":23762},{"id":23790},{"id":23788},{"id":23800},{"id":23801},{"id":23812},{"id":23816},{"id":23844},{"id":23876},{"id":23893},{"id":23895},{"id":23908},{"id":23924},{"id":23925},{"id":23936},{"id":23943},{"id":23955},{"id":23949},{"id":23981},{"id":24001},{"id":24043},{"id":24064},{"id":24067},{"id":24072},{"id":24080},{"id":24099},{"id":24108},{"id":24113},{"id":24120},{"id":24105},{"id":24126},{"id":24127},{"id":24134},{"id":24137},{"id":24140},{"id":24143},{"id":24147},{"id":24160},{"id":24163},{"id":24167},{"id":24169},{"id":24189},{"id":24198},{"id":24181},{"id":24211},{"id":24229},{"id":24231},{"id":24239},{"id":24251},{"id":24252},{"id":24253},{"id":24257},{"id":24259},{"id":24281},{"id":24285},{"id":24310},{"id":24311},{"id":24318},{"id":24319},{"id":24321},{"id":24325},{"id":24337},{"id":24339},{"id":24332},{"id":24351},{"id":24375},{"id":24376},{"id":24384},{"id":24394},{"id":24399},{"id":24400},{"id":24401},{"id":24403},{"id":24408},{"id":24424},{"id":24425},{"id":24455},{"id":24484},{"id":24547},{"id":24552},{"id":24578},{"id":24559},{"id":24581},{"id":24596},{"id":24598},{"id":24606},{"id":24624},{"id":24634},{"id":24642},{"id":24643},{"id":24653},{"id":24654},{"id":24669},{"id":24670},{"id":24674},{"id":24675},{"id":24678},{"id":24683},{"id":24692},{"id":24688},{"id":24708},{"id":24712},{"id":24720},{"id":24727},{"id":24733},{"id":24734},{"id":24746},{"id":25555},{"id":25571},{"id":25666},{"id":25819},{"id":25949},{"id":25979},{"id":26065},{"id":26222},{"id":26258},{"id":26260},{"id":26266},{"id":26249},{"id":26273},{"id":26296},{"id":26302},{"id":26321},{"id":26325},{"id":26336},{"id":26338},{"id":26354},{"id":26355},{"id":26357},{"id":26358},{"id":26362},{"id":26365},{"id":26366},{"id":26371},{"id":26380},{"id":26382},{"id":26384},{"id":26385},{"id":26367},{"id":26388},{"id":26391},{"id":26392},{"id":26405},{"id":26393},{"id":26413},{"id":26410},{"id":26411},{"id":26416},{"id":26420},{"id":26418},{"id":26421},{"id":26426},{"id":26427},{"id":26436},{"id":26440},{"id":26441},{"id":26443},{"id":26446},{"id":26428},{"id":26429},{"id":26448},{"id":26449},{"id":26453},{"id":26601},{"id":27005},{"id":27068},{"id":27200},{"id":27454},{"id":27480},{"id":27486},{"id":27499},{"id":27503},{"id":27510},{"id":27569},{"id":27567},{"id":27775},{"id":27990},{"id":28269},{"id":28934},{"id":28992},{"id":29252},{"id":29255},{"id":29262},{"id":29265},{"id":29268},{"id":29275},{"id":29282},{"id":29292},{"id":29296},{"id":29306},{"id":29321},{"id":29305},{"id":29333},{"id":29338},{"id":29353},{"id":29360},{"id":29363},{"id":29367},{"id":29379},{"id":29391},{"id":29402},{"id":29437},{"id":29444},{"id":29453},{"id":29456},{"id":29460},{"id":29462},{"id":29467},{"id":29513},{"id":29617},{"id":29618},{"id":29628},{"id":29638},{"id":29659},{"id":29662},{"id":29686},{"id":29696},{"id":29788},{"id":29793},{"id":29798},{"id":29809},{"id":29816},{"id":29819},{"id":29823},{"id":29824},{"id":29835},{"id":29868},{"id":29872},{"id":29878},{"id":29887},{"id":29895},{"id":29907},{"id":29908},{"id":29925}]',
 '[{"id":15517}]']
In [ ]:
 
In [190]:
for ema in emailids:
    #print(ema)
    jsema = (json.loads(ema))
    
    #print(jsema[0]['id'])
    print(jsema[0])
    emadlis.append(jsema[0])
    #print(emadlis[(jsema[0])])
    #for em in ema:
    #    print(em)
{'id': 6}
{'id': 4}
{'id': 15517}
In [195]:
random.randint(0,10)
Out[195]:
10
In [ ]:
 
In [194]:
emadlis[0]['id']
Out[194]:
6
In [143]:
import bs4
In [ ]:
bs4.BeautifulSoup()
In [ ]:
 
In [163]:
#for emaz in emadlis:
    #print(emaz['id'])
#    thema = (emailaddy + str(emaz['id']))
#    getema = requests.get(thema)
#    bstxt = (bs4.BeautifulSoup(getema.text))
#    print(bstxt.find_all('p'))
    #print(bs4.BeautifulSoup(getema))
[<p>This key's fingerprint is A04C 5E09 ED02 B328 03EB  6116 93ED 732E 9231 8DBA</p>, <p>If you need help using Tor you can contact WikiLeaks for assistance in setting it up using our simple webchat available at: <a href="https://wikileaks.org/talk">https://wikileaks.org/talk</a></p>, <p>If you can use Tor, but need to contact WikiLeaks for other reasons use our secured webchat available at <b>http://wlchatc3pjwpli5r.onion</b></p>, <p>We recommend contacting us over Tor if you can.</p>, <p><a href="https://www.torproject.org">Tor</a> is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>In order to use the WikiLeaks public submission system as detailed above you can download the Tor Browser Bundle, which is a Firefox-like browser available for Windows, Mac OS X and GNU/Linux and pre-configured to connect using the anonymising system Tor.</p>, <p>If you are at high risk and you have the capacity to do so, you can also access the submission system through a secure operating system called <a href="https://tails.boum.org">Tails</a>. Tails is an operating system launched from a USB stick or a DVD that aim to leaves no traces when the computer is shut down after use and automatically routes your internet traffic through Tor. Tails will require you to have either a USB stick or a DVD at least 4GB big and a laptop or desktop computer.</p>, <p>Our submission system works hard to preserve your anonymity, but we recommend you also take some of your own precautions. Please review these basic guidelines. </p>, <p>If you have a very large submission, or a submission with a complex format, or are a high-risk source, please <a href="#submit_help_contact">contact us</a>. In our experience it is always possible to find a custom solution for even the most seemingly difficult situations.</p>, <p>If the computer you are uploading from could subsequently be audited in an investigation, consider using a computer that is not easily tied to you. Technical users can also use <a href="https://tails.boum.org">Tails</a> to help ensure you do not leave any records of your submission on the computer.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you are a high-risk source, avoid saying anything or doing anything after submitting which might promote suspicion. In particular, you should try to stick to your normal routine and behaviour.</p>, <p>If you are a high-risk source and the computer you prepared your submission on, or uploaded it from, could subsequently be audited in an investigation, we recommend that you format and dispose of the computer hard drive and any other storage media you used.</p>, <p>In particular, hard drives retain data after formatting which may be visible to a digital forensics team and flash media (USB sticks, memory cards and SSD drives) retain data even after a secure erasure. If you used flash media to store sensitive data, it is important to destroy the media.</p>, <p>If you do this and are a high-risk source you should make sure there are no traces of the clean-up, since such traces themselves may draw suspicion.</p>, <p>If a legal action is brought against you as a result of your submission, there are organisations that may help you. The Courage Foundation is an international organisation dedicated to the protection of journalistic sources. You can find more details at <a href="https://www.couragefound.org">https://www.couragefound.org</a>.</p>, <p>WikiLeaks publishes documents of political or historical importance that are censored or otherwise suppressed. We specialise in strategic global publishing and large archives.</p>, <p>The following is the address of our secure site where you can anonymously upload your documents to WikiLeaks editors. You can only access this submissions system through Tor. (See our <a href="#submit_help_tor">Tor tab</a> for more information.) We also advise you to read our <a href="#submit_help_tips">tips for sources</a> before submitting.</p>, <p>If you cannot use Tor, or your submission is very large, or you have specific requirements, WikiLeaks provides several alternative methods. <a href="#submit_help_contact">Contact us</a> to discuss how to proceed.</p>, <p class="lead"><a href="/clinton-emails/">Back to the Search</a></p>, <p><a download="" href="/clinton-emails/Clinton_Email_August_Release/C05776573.pdf">Download Clinton_Email_August_Release/C05776573.pdf</a></p>, <p style="margin-top: 10px"><a href="https://www.wikileaks.org/plusd/">See Also US Diplomatic Cable Search</a></p>, <p class="efm-need-highlight" style="margin-top:0;padding-top:0">Click to send permalink to address bar, or right-click to copy permalink.</p>, <p style="margin:0.5em 0;padding:0;border-top:1px dotted #ccc;height:1px"></p>, <p>
</p>, <p>Tor is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>
</p>, <p>Tails is a live operating system, that you can start on almost any computer from a DVD, USB stick, or SD card. It aims at preserving your privacy and anonymity.</p>, <p>
</p>, <p>The Courage Foundation is an international organisation that supports those who risk life or liberty to make significant contributions to the historical record.</p>, <p>
</p>, <p>Bitcoin uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network.</p>]
[<p>This key's fingerprint is A04C 5E09 ED02 B328 03EB  6116 93ED 732E 9231 8DBA</p>, <p>If you need help using Tor you can contact WikiLeaks for assistance in setting it up using our simple webchat available at: <a href="https://wikileaks.org/talk">https://wikileaks.org/talk</a></p>, <p>If you can use Tor, but need to contact WikiLeaks for other reasons use our secured webchat available at <b>http://wlchatc3pjwpli5r.onion</b></p>, <p>We recommend contacting us over Tor if you can.</p>, <p><a href="https://www.torproject.org">Tor</a> is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>In order to use the WikiLeaks public submission system as detailed above you can download the Tor Browser Bundle, which is a Firefox-like browser available for Windows, Mac OS X and GNU/Linux and pre-configured to connect using the anonymising system Tor.</p>, <p>If you are at high risk and you have the capacity to do so, you can also access the submission system through a secure operating system called <a href="https://tails.boum.org">Tails</a>. Tails is an operating system launched from a USB stick or a DVD that aim to leaves no traces when the computer is shut down after use and automatically routes your internet traffic through Tor. Tails will require you to have either a USB stick or a DVD at least 4GB big and a laptop or desktop computer.</p>, <p>Our submission system works hard to preserve your anonymity, but we recommend you also take some of your own precautions. Please review these basic guidelines. </p>, <p>If you have a very large submission, or a submission with a complex format, or are a high-risk source, please <a href="#submit_help_contact">contact us</a>. In our experience it is always possible to find a custom solution for even the most seemingly difficult situations.</p>, <p>If the computer you are uploading from could subsequently be audited in an investigation, consider using a computer that is not easily tied to you. Technical users can also use <a href="https://tails.boum.org">Tails</a> to help ensure you do not leave any records of your submission on the computer.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you are a high-risk source, avoid saying anything or doing anything after submitting which might promote suspicion. In particular, you should try to stick to your normal routine and behaviour.</p>, <p>If you are a high-risk source and the computer you prepared your submission on, or uploaded it from, could subsequently be audited in an investigation, we recommend that you format and dispose of the computer hard drive and any other storage media you used.</p>, <p>In particular, hard drives retain data after formatting which may be visible to a digital forensics team and flash media (USB sticks, memory cards and SSD drives) retain data even after a secure erasure. If you used flash media to store sensitive data, it is important to destroy the media.</p>, <p>If you do this and are a high-risk source you should make sure there are no traces of the clean-up, since such traces themselves may draw suspicion.</p>, <p>If a legal action is brought against you as a result of your submission, there are organisations that may help you. The Courage Foundation is an international organisation dedicated to the protection of journalistic sources. You can find more details at <a href="https://www.couragefound.org">https://www.couragefound.org</a>.</p>, <p>WikiLeaks publishes documents of political or historical importance that are censored or otherwise suppressed. We specialise in strategic global publishing and large archives.</p>, <p>The following is the address of our secure site where you can anonymously upload your documents to WikiLeaks editors. You can only access this submissions system through Tor. (See our <a href="#submit_help_tor">Tor tab</a> for more information.) We also advise you to read our <a href="#submit_help_tips">tips for sources</a> before submitting.</p>, <p>If you cannot use Tor, or your submission is very large, or you have specific requirements, WikiLeaks provides several alternative methods. <a href="#submit_help_contact">Contact us</a> to discuss how to proceed.</p>, <p class="lead"><a href="/clinton-emails/">Back to the Search</a></p>, <p><a download="" href="/clinton-emails/Clinton_Email_August_Release/C05777242.pdf">Download Clinton_Email_August_Release/C05777242.pdf</a></p>, <p style="margin-top: 10px"><a href="https://www.wikileaks.org/plusd/">See Also US Diplomatic Cable Search</a></p>, <p class="efm-need-highlight" style="margin-top:0;padding-top:0">Click to send permalink to address bar, or right-click to copy permalink.</p>, <p style="margin:0.5em 0;padding:0;border-top:1px dotted #ccc;height:1px"></p>, <p>
</p>, <p>Tor is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>
</p>, <p>Tails is a live operating system, that you can start on almost any computer from a DVD, USB stick, or SD card. It aims at preserving your privacy and anonymity.</p>, <p>
</p>, <p>The Courage Foundation is an international organisation that supports those who risk life or liberty to make significant contributions to the historical record.</p>, <p>
</p>, <p>Bitcoin uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network.</p>]
[<p>This key's fingerprint is A04C 5E09 ED02 B328 03EB  6116 93ED 732E 9231 8DBA</p>, <p>If you need help using Tor you can contact WikiLeaks for assistance in setting it up using our simple webchat available at: <a href="https://wikileaks.org/talk">https://wikileaks.org/talk</a></p>, <p>If you can use Tor, but need to contact WikiLeaks for other reasons use our secured webchat available at <b>http://wlchatc3pjwpli5r.onion</b></p>, <p>We recommend contacting us over Tor if you can.</p>, <p><a href="https://www.torproject.org">Tor</a> is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>In order to use the WikiLeaks public submission system as detailed above you can download the Tor Browser Bundle, which is a Firefox-like browser available for Windows, Mac OS X and GNU/Linux and pre-configured to connect using the anonymising system Tor.</p>, <p>If you are at high risk and you have the capacity to do so, you can also access the submission system through a secure operating system called <a href="https://tails.boum.org">Tails</a>. Tails is an operating system launched from a USB stick or a DVD that aim to leaves no traces when the computer is shut down after use and automatically routes your internet traffic through Tor. Tails will require you to have either a USB stick or a DVD at least 4GB big and a laptop or desktop computer.</p>, <p>Our submission system works hard to preserve your anonymity, but we recommend you also take some of your own precautions. Please review these basic guidelines. </p>, <p>If you have a very large submission, or a submission with a complex format, or are a high-risk source, please <a href="#submit_help_contact">contact us</a>. In our experience it is always possible to find a custom solution for even the most seemingly difficult situations.</p>, <p>If the computer you are uploading from could subsequently be audited in an investigation, consider using a computer that is not easily tied to you. Technical users can also use <a href="https://tails.boum.org">Tails</a> to help ensure you do not leave any records of your submission on the computer.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you have any issues talk to WikiLeaks. We are the global experts in source protection – it is a complex field. Even those who mean well often do not have the experience or expertise to advise properly. This includes other media organisations.</p>, <p>If you are a high-risk source, avoid saying anything or doing anything after submitting which might promote suspicion. In particular, you should try to stick to your normal routine and behaviour.</p>, <p>If you are a high-risk source and the computer you prepared your submission on, or uploaded it from, could subsequently be audited in an investigation, we recommend that you format and dispose of the computer hard drive and any other storage media you used.</p>, <p>In particular, hard drives retain data after formatting which may be visible to a digital forensics team and flash media (USB sticks, memory cards and SSD drives) retain data even after a secure erasure. If you used flash media to store sensitive data, it is important to destroy the media.</p>, <p>If you do this and are a high-risk source you should make sure there are no traces of the clean-up, since such traces themselves may draw suspicion.</p>, <p>If a legal action is brought against you as a result of your submission, there are organisations that may help you. The Courage Foundation is an international organisation dedicated to the protection of journalistic sources. You can find more details at <a href="https://www.couragefound.org">https://www.couragefound.org</a>.</p>, <p>WikiLeaks publishes documents of political or historical importance that are censored or otherwise suppressed. We specialise in strategic global publishing and large archives.</p>, <p>The following is the address of our secure site where you can anonymously upload your documents to WikiLeaks editors. You can only access this submissions system through Tor. (See our <a href="#submit_help_tor">Tor tab</a> for more information.) We also advise you to read our <a href="#submit_help_tips">tips for sources</a> before submitting.</p>, <p>If you cannot use Tor, or your submission is very large, or you have specific requirements, WikiLeaks provides several alternative methods. <a href="#submit_help_contact">Contact us</a> to discuss how to proceed.</p>, <p class="lead"><a href="/clinton-emails/">Back to the Search</a></p>, <p><a download="" href="/clinton-emails/Clinton_Email_June_Release/C05762707.pdf">Download Clinton_Email_June_Release/C05762707.pdf</a></p>, <p style="margin-top: 10px"><a href="https://www.wikileaks.org/plusd/">See Also US Diplomatic Cable Search</a></p>, <p class="efm-need-highlight" style="margin-top:0;padding-top:0">Click to send permalink to address bar, or right-click to copy permalink.</p>, <p style="margin:0.5em 0;padding:0;border-top:1px dotted #ccc;height:1px"></p>, <p>
</p>, <p>Tor is an encrypted anonymising network that makes it harder to intercept internet communications, or see where communications are coming from or going to.</p>, <p>
</p>, <p>Tails is a live operating system, that you can start on almost any computer from a DVD, USB stick, or SD card. It aims at preserving your privacy and anonymity.</p>, <p>
</p>, <p>The Courage Foundation is an international organisation that supports those who risk life or liberty to make significant contributions to the historical record.</p>, <p>
</p>, <p>Bitcoin uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network.</p>]
In [93]:
reqrecipt = ('https://www.leaksapi.com/clinton-emails/to/8a52166f-1ff2-4060-9215-3583895df339/')
In [177]:
reqem = ('https://www.leaksapi.com/clinton-emails/id/8a52166f-1ff2-4060-9215-3583895df339/1')
In [178]:
reqem
Out[178]:
'https://www.leaksapi.com/clinton-emails/id/8a52166f-1ff2-4060-9215-3583895df339/1'
In [180]:
rqg = requests.get(reqem)
In [182]:
rqg.text
Out[182]:
'{"to":"Philippe Reines","timestamp":"2010-06-30 11:53","subject":"TEST","raw":"<div class=\\"tab-pane fade in active\\" id=\\"content\\"><header id=\\"header\\">\\n\\t\\t\\t\\t\\tFrom: <span title=\\"Original: Hillary Clinton\\">Hillary Clinton</span>\\n\\t\\t\\t\\t\\tTo: <span title=\\"Original: preines\\">Philippe Reines</span>\\n\\t\\t\\t\\t\\tDate: 2010-06-30 11:53\\n\\t\\t\\t\\t\\tSubject: TEST\\n\\t\\t\\t\\t</header><div class=\\"email-content\\" id=\\"uniquer\\"><span class=\\"unclassified\\">UNCLASSIFIED U.S. Department of State Case No. F-2014-20439 Doc No. C05775316 Date: 08/31/2015</span><span class=\\"unclassified\\">RELEASE IN PART</span>\\n                                                                                                              B6\\n\\n<span class=\\"inlinemeta\\">From:  \\t                               H <hrod17@clintonemail.com >\\n</span><span class=\\"inlinemeta\\">Sent:\\t                                 Thursday, July 1, 2010 6:53 PM\\nTo:   \\t                                \'preines\\n</span><span class=\\"inlinemeta\\">Subject:\\t                              Re: Test\\n</span>\\n\\nReceived.\\n\\n\\t    <span class=\\"inlinemeta\\">Original Message</span><span class=\\"inlinemeta\\">From: PIR <preines\\n</span><span class=\\"inlinemeta\\">To: H\\n</span><span class=\\"inlinemeta\\">Cc: Lona J Valmoro <ValmoroU@state.gov>\\nSent: Thu Jul 01 18:52:18 2010\\nSubject: Test\\n</span>\\n\\nTesting in-flight communication\\n\\nSent from my iPad\\n\\t\\t\\t\\t</div></div>","pdf":"https://www.wikileaks.org/clinton-emails/Clinton_Email_August_Release/C05775316.pdf","id":1,"from":"Hillary Clinton","body":"UNCLASSIFIED U.S. Department of State Case No. F-2014-20439 Doc No. C05775316 Date: 08/31/2015RELEASE IN PART\\n                                                                                                              B6\\n\\nFrom:  \\t                               H <hrod17@clintonemail.com >\\nSent:\\t                                 Thursday, July 1, 2010 6:53 PM\\nTo:   \\t                                \'preines\\nSubject:\\t                              Re: Test\\n\\n\\nReceived.\\n\\n\\t    Original MessageFrom: PIR <preines\\nTo: H\\nCc: Lona J Valmoro <ValmoroU@state.gov>\\nSent: Thu Jul 01 18:52:18 2010\\nSubject: Test\\n\\n\\nTesting in-flight communication\\n\\nSent from my iPad\\n\\t\\t\\t\\t"}'
In [ ]:
 
In [ ]:
 
In [54]:
#[subnam.strip() for s in subnam['1:-1'].split(',')]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-54-5ef7b00f963b> in <module>()
----> 1 [subnam.strip() for s in subnam['1:-1'].split(',')]

TypeError: string indices must be integers
In [62]:
snm = subnam.replace('[]', "")
In [64]:
type(snm)
Out[64]:
str
In [65]:
snmz = list(snm)
In [2]:
giphypop.random_gif()
/usr/local/lib/python3.4/dist-packages/giphypop.py:233: UserWarning: You are using the giphy public api key. This should be used for testing only and may be deactivated in the future. See https://github.com/Giphy/GiphyAPI.
  warnings.warn('You are using the giphy public api key. This should be used for testing only '
Out[2]:
GiphyImage<xTcnTkVDUvIYV1X4wo> at http://giphy.com/gifs/martin-luther-king-jr-mlk-mkl-xTcnTkVDUvIYV1X4wo
In [17]:
trusear = giphypop.search('trump')
/usr/local/lib/python3.4/dist-packages/giphypop.py:233: UserWarning: You are using the giphy public api key. This should be used for testing only and may be deactivated in the future. See https://github.com/Giphy/GiphyAPI.
  warnings.warn('You are using the giphy public api key. This should be used for testing only '
In [18]:
trumplist = list()
In [ ]:
 
In [19]:
for tru in trusear:
    #print(tru.media_url)
    trumplist.append(tru.media_url)
In [26]:
random.choice(trumplist)
Out[26]:
'http://media1.giphy.com/media/rzKSHEMN0lVkc/giphy.gif'
In [ ]:
 
In [20]:
trumplist
Out[20]:
['http://media4.giphy.com/media/l0HlzECw20Y4dK20o/giphy.gif',
 'http://media3.giphy.com/media/3o6Zt4FFBn6Je1lBao/giphy.gif',
 'http://media1.giphy.com/media/l396HKg4zkUrK1ihy/giphy.gif',
 'http://media0.giphy.com/media/l0MYvt61Tr7KMOQy4/giphy.gif',
 'http://media3.giphy.com/media/l2Sqb2raeiZLVDFaU/giphy.gif',
 'http://media3.giphy.com/media/A2LScHLeGzzLa/giphy.gif',
 'http://media1.giphy.com/media/l2SpQq3S9e0HE89oI/giphy.gif',
 'http://media0.giphy.com/media/3o6ZsZoPzWFYLv7l5u/giphy.gif',
 'http://media3.giphy.com/media/3o7TKsyXonvr2mv9mw/giphy.gif',
 'http://media2.giphy.com/media/3oz8xtl7fxDIncrcKA/giphy.gif',
 'https://media1.giphy.com/media/26tn8u4JaBPQmq8mY/giphy.gif',
 'http://media2.giphy.com/media/jSB2l4zJ82Rvq/giphy.gif',
 'http://media0.giphy.com/media/3oEjHS0LAZXyNo0eXu/giphy.gif',
 'http://media3.giphy.com/media/3o6ZsVbs2GzgKNvVpS/giphy.gif',
 'http://media1.giphy.com/media/3o7TKPpgPl68uSeIO4/giphy.gif',
 'http://media1.giphy.com/media/z619OZp86JaBG/giphy.gif',
 'http://media0.giphy.com/media/3o85xtWMj6Hbv1PakE/giphy.gif',
 'http://media1.giphy.com/media/l0MYAH89fiNMdBYFW/giphy.gif',
 'http://media0.giphy.com/media/3o7TKUMk1IysRprsis/giphy.gif',
 'http://media1.giphy.com/media/oxsfuzJuJzCjm/giphy.gif',
 'http://media4.giphy.com/media/l46CahdcL5yYTaQiQ/giphy.gif',
 'http://media4.giphy.com/media/3o72EVhs2Fu38uVFv2/giphy.gif',
 'http://media2.giphy.com/media/l0HlW09N6z8ZVSnok/giphy.gif',
 'http://media4.giphy.com/media/l46CgWQ7xeOkNI1SU/giphy.gif',
 'http://media1.giphy.com/media/rzKSHEMN0lVkc/giphy.gif']

thecatjson

The Cat Json

Returns json result of random cat images instead of xml

In [26]:
import json
import requests
import xmltodict
from flask import Flask, jsonify
from flask_restful import Resource, Api
import random
In [27]:
app = Flask(__name__)
api = Api(app)
In [28]:
catreq = (requests.get('http://thecatapi.com/api/images/get?format=xml&results_per_page=50'))
In [29]:
catxt = catreq.text
In [30]:
catdict = xmltodict.parse(catxt)
In [31]:
caim = catdict['response']['data']['images']['image']
In [32]:
class HelloWorld(Resource):
    def get(self):
        jsdump = caim[random.randint(0,49)]

        return (json.loads(json.dumps(jsdump)))
In [33]:
api.add_resource(HelloWorld, '/')
In [34]:
if __name__ == '__main__':
    app.run(debug=True)
An exception has occurred, use %tb to see the full traceback.

SystemExit: 1
To exit: use 'exit', 'quit', or Ctrl-D.
In [ ]:
 

akl-uni-comps

auckland university computers

exploring the auckland university SIT API

In [6]:
import requests
import json
In [3]:
labreqmach = requests.get('http://www.fos.auckland.ac.nz/api/lab/machines/1.json')
In [8]:
labmachdic = json.loads(labreqmach.text)
In [12]:
lenmach = len(labmachdic)
In [15]:
labmachdic[lenmach]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-15-9b063b18b537> in <module>()
----> 1 labmachdic[lenmach]

IndexError: list index out of range
In [28]:
for labm in range(0, lenmach):
    print(labmachdic[labm]['ip'])
10.103.139.124
10.103.139.123
10.103.139.122
10.103.139.121
10.103.139.120
10.103.139.119
10.103.139.118
10.103.139.117
10.103.139.116
10.103.139.115
10.103.139.114
10.103.139.113
10.103.139.112
10.103.139.111
10.103.139.110
10.103.139.109
10.103.139.108
10.103.139.107
10.103.139.106
10.103.139.105
10.103.139.104
10.103.139.103
10.103.139.102
10.103.139.101
10.103.139.100
10.103.139.99
10.103.139.98
10.103.139.97
10.103.139.96
10.103.139.95
10.103.139.94
10.103.139.93
10.103.139.92
10.103.139.91
10.103.139.90
10.103.139.89
10.103.139.88
10.103.139.87
10.103.139.86
10.103.139.85
10.103.139.84
10.103.139.83
10.103.139.82
10.103.139.81
10.103.139.80
10.103.139.79
10.103.139.78
10.103.139.77
10.103.139.76
10.103.139.75
10.103.139.74
10.103.139.73
10.103.139.72
10.103.139.71
10.103.139.70
10.103.139.69
10.103.139.68
10.103.139.67
10.103.139.66
10.103.139.65
10.103.139.64
10.103.139.63
10.103.139.62
10.103.139.61
10.103.139.60
10.103.139.59
10.103.139.58
10.103.139.57
10.103.139.56
10.103.139.55
10.103.139.54
10.103.139.53
10.103.139.52
10.103.139.51
10.103.139.50
10.103.139.49
10.103.139.48
10.103.139.47
10.103.139.46
10.103.139.45
10.103.139.44
10.103.139.43
10.103.139.42
10.103.139.41
10.103.139.40
10.103.139.39
10.103.139.38
10.103.139.37
10.103.139.36
10.103.139.35
10.103.139.34
10.103.139.33
10.103.139.32
10.103.139.31
10.103.139.30
10.103.139.29
10.103.139.28
10.103.139.27
10.103.139.26
10.103.139.25
10.103.139.24
10.103.139.23
10.103.139.22
10.103.139.21
10.103.139.20
10.103.139.19
10.103.139.18
10.103.139.17
10.103.139.16
10.103.139.15
10.103.139.14
10.103.139.13
10.103.139.12
10.103.139.11
10.103.139.10
10.103.139.9
10.103.139.8
10.103.139.7
10.103.139.6
10.103.139.5
10.103.139.4
10.103.139.3
10.103.139.2
10.103.139.1
10.103.139.126
In [29]:
labdet = requests.get('http://www.fos.auckland.ac.nz/api/lab/current_usage/1.json')
In [31]:
labdet.text
Out[31]:
'[{"machines_in_use": 56, "name": "FCL", "current_tutorial": null, "next_tutorial": null, "total_machines": 125, "id": 1, "closed": false, "timestamp": "2016/10/11 18:57:21 +1300", "room": "303s-191"}]'
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [25]:
for labm in range(0, lenmach):
    print(labmachdic[labm]['in_use'])
    #if True in (labmachdic[labm]['in_use']):
    #    print(labmachdic[labm]['in_use'])
False
False
False
False
False
False
True
False
True
False
True
True
True
False
True
True
False
False
False
True
True
False
True
False
False
False
False
False
True
False
False
True
True
False
False
True
True
True
True
True
False
False
True
True
True
True
False
False
True
False
False
True
True
False
False
False
True
False
False
False
False
False
False
True
False
False
False
True
True
False
False
False
True
False
True
False
True
True
False
False
False
True
False
True
False
True
True
True
False
True
False
True
True
False
True
True
True
True
True
True
False
True
True
True
False
False
False
False
True
True
True
False
False
False
False
False
True
True
False
True
False
False
False
False
False
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 

testtesla

Control Tesla Cars

Test setting temp based on local weather.

driver_temp=

passenger_temp=

This is a delivery system. replace buses in cities with electrical cars. These cars run the same route as buses.

Going to change the radio

More indepth Tesla car stats. Returns the Raspberry Pi media system onboard that is used to stream media to the car. Pluhs in to the cars stero. Allows passangers in the bar to reclievve calls. Broadcast wifi. Each car has its own router that it uses to comm with the outside world. Canera t oo report how everything is goiing. If things are wrong realtime images of what is happening. The ability to for remote login and control. HAM Radio broadcast. Each car is broadcasting a media center that offers storage space and media. You are able to connect to any of these Tesla cars and access the services they offer. If for some reason they are not to total standards then you can retry.

Nux the

Switch between low and high heat.

passanger temp

config file with times to auto start the car. driverless commands. sync to meetup and drive to where the meetups are happening

{ "response": { "inside_temp": 17.0, // degC inside car "outside_temp": 9.5, // degC outside car or null "driver_temp_setting": 22.6, // degC of driver temperature setpoint "passenger_temp_setting": 22.6, // degC of passenger temperature setpoint "is_auto_conditioning_on": false, // apparently even if on "is_front_defroster_on": null, // null or boolean as integer? "is_rear_defroster_on": false, "fan_status": 0 // fan speed 0-6 or null } }

In [2]:
import json
#import nose
from cryptography.fernet import Fernet
import getpass
import pandas
In [ ]:
myusr = getpass.getuser()
In [7]:
tespas = getpass.getpass('PASSWORD ')
PASSWORD ········
In [9]:
mydict = ({ "response": { "df": False, "dr": False, "pf": False, "pr": False, "ft": False, "rt": False, "car_verson": "1.19.42", "locked": True, "sun_roof_installed": False, "sun_roof_state": "unknown", "sun_roof_percent_open": 0, "dark_rims": False, "wheel_type": "Base19", "has_spoiler": False, "roof_color": "Colored", "perf_config": "Base" } })
In [10]:
tespas
Out[10]:
'test'
In [11]:
pandas.DataFrame(mydict)
Out[11]:
response
car_verson 1.19.42
dark_rims False
df False
dr False
ft False
has_spoiler False
locked True
perf_config Base
pf False
pr False
roof_color Colored
rt False
sun_roof_installed False
sun_roof_percent_open 0
sun_roof_state unknown
wheel_type Base19
In [16]:
key = Fernet.generate_key()

f = Fernet(key)
token = f.encrypt(b'straz')
print(token)
'...'
f.decrypt(token)
b'gAAAAABX-5fRdIVRQf8vPSMZGEa7MW1Y9kxc5gv5XAUB9bHf0482Bk6vYuO-4Jy1zpfLTR7azjJew_JBh92cqrZ9Fw931daYaQ=='
Out[16]:
b'straz'
In [17]:
key
Out[17]:
b'z-FQnyhiZIL6ZWxd5tUCWxYaHQaEK4KFPlIshGKRgBM='
In [18]:
tesveh = 'https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password='
In [19]:
tesveh
Out[19]:
'https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password='
In [21]:
#from urllib2 import Request, urlopen

#headers = {
#  'Authorization': 'Bearer {access_token}'
#}
#request = Request('https://owner-api.teslamotors.com/api/1/vehicles/1/command/remote_start_drive?password=edisonsux', headers=headers)

#response_body = urlopen(request).read()
#print response_body
In [22]:
doorquen = (mydict['response']['df'], mydict['response']['dr'], mydict['response']['pf'], mydict['response']['pr'])
In [23]:
doorquen
Out[23]:
(False, False, False, False)
In [24]:
key
Out[24]:
b'z-FQnyhiZIL6ZWxd5tUCWxYaHQaEK4KFPlIshGKRgBM='
In [26]:
keyencr = f.encrypt(key)
In [27]:
keyencr
Out[27]:
b'gAAAAABX-5gkD9fwfYgaYhD3L-JLdwX9RTHr2cezBZTJ5zgyJCSzbJnNZznkB0DAY6ka5sfsbqoEZ5jOyryU_gXxvd38H3k5o_r1KRF7DecTPHb_wVspVd9XLw9q3jLr1NF_nVBxgBAW'
In [28]:
f.decrypt(token)
Out[28]:
b'straz'
In [29]:
TESLACONFIG = ('TESLA CONTROL BRUM BRUM')
In [30]:
print(TESLACONFIG)
TESLA CONTROL BRUM BRUM
In [ ]:
 
In [31]:
passwrdz = getpass.getpass("PASSWORD ENTER ")

askmileorkilo = input('AMERICAN SETTINGS Y/n ')

setlowtemp = input('DRIVER LOW TEMP SET AS: ')

sethightemp = input('DRIVER HIGH TEMP SET AS: ')


setpasslow = input('PASS LOW TEMP SET AS: ')

setpashight = input('PASS HIGH TEMP SET AS: ')

openDriversDoor = input('OPEN DRIVERS DOOR Y/n ')

unlockcar = input('UNLOCK CAR Y/n ')

valetmode = input('VALET MODE Y/n ')

valetpass = getpass.getpass('4 PIN NUMBER: ')
PASSWORD ENTER ········
AMERICAN SETTINGS Y/n Y
DRIVER LOW TEMP SET AS: 12
DRIVER HIGH TEMP SET AS: 15
PASS LOW TEMP SET AS: 10
PASS HIGH TEMP SET AS: 16
OPEN DRIVERS DOOR Y/n Y
UNLOCK CAR Y/n Y
VALET MODE Y/n Y
4 PIN NUMBER: ········
In [32]:
passwrdz
Out[32]:
'qwe'
In [33]:
valint = int(valetpass)
In [34]:
SETCURRENTZ = input('Current from -1 to 1: ')
Current from -1 to 1: 1
In [35]:
flsecur = float(SETCURRENTZ)
In [36]:
flsecur
Out[36]:
1.0
In [37]:
int(SETCURRENTZ)
Out[37]:
1
In [39]:
import cryptography
In [183]:
#fercypo = cryptography.fernet()

{ "portal_url": "https://owner-api.teslamotors.com/api/1/vehicles/", "stream_url": "https://streaming.vn.teslamotors.com/stream/", "username": "yourMyTeslaLogin@email.com", "password": "yourPassword", "output_file": "stream_output.txt" }

In [41]:
f.generate_key()
Out[41]:
b'Fy3UWE2Hg_dfPQMi34D3_3wsa5Fnxl0iTCXWHm3E5qs='
In [43]:
token = f.encrypt(bytes(valint))
In [44]:
print(token)
b'gAAAAABX-5iJmrFOHgUji6u3hkGCofgKBsmWq7p4Iftoxj7AHyf_SHAA_v7voz5NXOvqu2ptTeqmhkxaR3YWTBitoZVK47IxcdBRII_hb8JzileS9naLjnLuDjmmFSh0zGMmvFZELJdxOQeEBDDP6kl7UMiWkFTl_y3NK0hk_BsicG3kSqbRQvmuo7Yvz6wBb7LPMMOIpCFlMK5Xqyd4Eyv20_y2qTrdR7KwbPKyXeYSHS8DSp0JWO72rRqAfGUJehV9oI1JVeofLrakjHYiubOVHvDDcIs0H9HPulbyVUSrF1VDb-ct4WQPVdkrosuHfA2bJT_t5WtA6zr4kKSS6DpenC8G6-bAAfaLdLZ2qraZJlbCmDJ3C4zL7AgWDA98hmtDN3X-mR2NCcleHqM0X8reNxD8O-VJiTZOxUkOS2Piyo32lI4FpNgnSGrjFaIE3JAWjyyHHXWQBysTi5S8fkGX9Fc--szZnKaZ7FFu-7HHOSw4G1WwU4LVaG6ibfB43-qacA8B_EpV711AT_vmugjUk933eHH3IO4uJmFSap1nSwcaWzgEF41hsBDtPxxifDDBOclAz0aIwqJpq4PWmxMdL3iXsEEl6GHiTerbixHvBVqVoxbjMgEo2x6ULH9cJJW0Bv5wQEsJFAej-Uf2y4HgGLVrMJS1gcze7AYqGO5n5jsLB9KEbD3ZYg6xBm6mZe4eQbfizf7AGLJW_qLK_T22UohS-Wtt47wyFiZ2_NUEz5vm77f9UkfjQuOSJnJ52jpsUL9XBcjH4er_W61yMpaHU14lSJa5hjWiB15iq0Fah-fv_nmHdLS6v8u7nSnBsoNG5Z4paVn_joBFD7eERdWCCLl09Y7T8SLp9wq6M7_I6KOceJYht_6xIPImDcthtRg1G5nzQj52u4QMG0YioEfVxO9F7-ocbo3Irva_uhmoao23l0Mnt_YfrEr5erL_xxtFsfI1N1rs8V2Ki7yxrg2hFVTcXkv4z6v2ovfAHASJaWNSzw1406JveN-ZDCJBQvCI2kHqFDcsmN4zHktQnJmkG2TZteO3cJA30aD7EMqbGDYv5WWh0JQplNrqg-dg9ZOD1L8hqeVjmqv8_yOxFVm12e6TeW2LXADerdCML67DdfHh0kjhTyGMSPdaLoPwk3gRbXnADsz9VCIAGQMnpyEcbnFYnLO4eDs5KeT01cBqF_T_A1EfFjgFVM9daBKfewHyI19DDmOWKFHPgY5p-5pDpt2v5zrwjJ8wrBFsGrotyH_A7bkpC2p4p1KcRoqf5u2NwJlCB6CKzdPyWdHbm-f9JQ_tLwpKmm0X0Lt11t9sf0ApVNFGEp6T3rd5f8nwEH7bq7OmCbXeLV5xmvqI1hX84MuLu2ZoRSflO1osmOfEeRlse3qvE8j0Jk-K4gDUH2BDlkUrUv5ij3KMqSDVR2oiPKl2Za9dT6wWPWMhzefvGjgkXZATzkPM4hVjaCA-6M6NNAMxlRLgTvrXwQTu3J3HZQ-8HPGn-ntUzx_RBSbHmHV4q63piREC_9SswFthJYoMCL4jY5lkHnsH-zKGC2x20nCib9QyiKYGQsFcCVq37CqPfUDCx-CVK2qjRO89dn9seFXaPI4Jsr4dGNHOt1Q3MSTCaeoMsODnpzwgjv4dq1r_utrOG_bMMac3Bg0JMsC_KWo8gxf_mVMvhERmZCizapav2geJtbJM5234X3SoDmqnAfQHPZxR5FpWVvo_8xoms2okByh2'
In [45]:
f.decrypt(token)
Out[45]:
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
In [46]:
int.from_bytes((f.decrypt(token)), byteorder='big')
Out[46]:
0
In [47]:
byedecrpt = (f.decrypt(token))
In [48]:
int.from_bytes((byedecrpt), byteorder='big')
Out[48]:
0
In [50]:
if 'n' in valetmode:
    valeton = False
elif 'Y' in valetmode:
    valeton = True
    
In [52]:
if 'n' in askmileorkilo:
    miletru = False
elif 'Y' in askmileorkilo:
    miletru = True
In [53]:
askmileorkilo
Out[53]:
'Y'
In [54]:
miletru
Out[54]:
True
In [55]:
if miletru == True:
    guidisuni = "mi/hr"
elif miletru == False:
    guidisuni = "km/hr"
In [56]:
guidisuni
Out[56]:
'mi/hr'
In [57]:
if 'n' in unlockcar:
    opddor = False
elif 'Y' in unlockcar:
    opddor = True
In [58]:
opddor
Out[58]:
True
In [59]:
if 'n' in openDriversDoor:
    opddor = False
    
elif 'Y' in openDriversDoor:
    opddor = True
    
    
In [60]:
opddor
Out[60]:
True
In [61]:
import configparser
In [62]:
dfstat = (mydict['response']['df'])
In [63]:
pfstat = (mydict['response']['pf'])
In [64]:
prstat = (mydict['response']['pr'])
In [65]:
drstat = (mydict['response']['dr'])
In [66]:
drstat
Out[66]:
False
In [67]:
prstat
Out[67]:
False
In [68]:
dfstat
Out[68]:
False
In [69]:
pfstat
Out[69]:
False
In [70]:
import arrow
In [71]:
timnow = arrow.now()
In [72]:
print(timnow.datetime)
2016-10-11 02:34:18.627450+13:00
In [73]:
timnow.for_json()
Out[73]:
'2016-10-11T02:34:18.627450+13:00'
In [74]:
timnow.isoweekday()
Out[74]:
2
In [75]:
timnow.humanize()
Out[75]:
'just now'
In [76]:
timnow.isoweekday()
Out[76]:
2
In [77]:
timnow.isocalendar()
Out[77]:
(2016, 41, 2)
In [78]:
timnow.ceil
Out[78]:
<bound method Arrow.ceil of <Arrow [2016-10-11T02:34:18.627450+13:00]>>
In [79]:
timnow.clone()
Out[79]:
<Arrow [2016-10-11T02:34:18.627450+13:00]>
In [80]:
timnow.date()
Out[80]:
datetime.date(2016, 10, 11)
In [81]:
timnow.format()
Out[81]:
'2016-10-11 02:34:18+13:00'
In [82]:
timnow.floor
Out[82]:
<bound method Arrow.floor of <Arrow [2016-10-11T02:34:18.627450+13:00]>>
In [83]:
timnow.float_timestamp
Out[83]:
1476106458.62745
In [84]:
timz = timnow.for_json()
In [85]:
timz
Out[85]:
'2016-10-11T02:34:18.627450+13:00'
In [86]:
print(timz)
2016-10-11T02:34:18.627450+13:00
In [87]:
timz.upper()
Out[87]:
'2016-10-11T02:34:18.627450+13:00'
In [88]:
timz.split('-' and ':' and '.')
Out[88]:
['2016-10-11T02:34:18', '627450+13:00']
In [89]:
print(timnow)
2016-10-11T02:34:18.627450+13:00
In [90]:
timutc = timnow.utcnow()
In [ ]:
 
In [91]:
timnow.weekday()
Out[91]:
1
In [92]:
timnow.dst()
Out[92]:
datetime.timedelta(0, 3600)
In [93]:
timnow.ctime()
Out[93]:
'Tue Oct 11 02:34:18 2016'
In [95]:
arrow.util.total_seconds
Out[95]:
<function arrow.util._total_seconds_27>
In [96]:
arrow.api.factory
Out[96]:
<function arrow.api.factory>
In [97]:
artz = arrow.factory.tzinfo(timutc)
In [99]:
calcsee= arrow.locales.calendar.HTMLCalendar()
In [100]:
calcsee.formatmonth(2016, 5)
Out[100]:
'<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr><th colspan="7" class="month">May 2016</th></tr>\n<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>\n<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sun">1</td></tr>\n<tr><td class="mon">2</td><td class="tue">3</td><td class="wed">4</td><td class="thu">5</td><td class="fri">6</td><td class="sat">7</td><td class="sun">8</td></tr>\n<tr><td class="mon">9</td><td class="tue">10</td><td class="wed">11</td><td class="thu">12</td><td class="fri">13</td><td class="sat">14</td><td class="sun">15</td></tr>\n<tr><td class="mon">16</td><td class="tue">17</td><td class="wed">18</td><td class="thu">19</td><td class="fri">20</td><td class="sat">21</td><td class="sun">22</td></tr>\n<tr><td class="mon">23</td><td class="tue">24</td><td class="wed">25</td><td class="thu">26</td><td class="fri">27</td><td class="sat">28</td><td class="sun">29</td></tr>\n<tr><td class="mon">30</td><td class="tue">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>\n</table>\n'
In [101]:
arnow = arrow.now()
In [102]:
dayweekz = arnow.weekday()
In [103]:
dayweekz
Out[103]:
1
In [104]:
calcsee.getfirstweekday()
Out[104]:
0
In [105]:
calcsee.getfirstweekday()
Out[105]:
0
In [109]:
arnow.strftime('%M')
Out[109]:
'35'
In [110]:
arnow.strftime('%m')
Out[110]:
'10'
In [111]:
arnow.strftime('%Y %m')
Out[111]:
'2016 10'
In [ ]:
 
In [112]:
yrints = int(arnow.strftime('%Y'))
In [113]:
yrints
Out[113]:
2016
In [114]:
mondayfor = int(arnow.strftime('%m'))
In [115]:
mondayfor
Out[115]:
10
In [116]:
daydatye = int(arnow.strftime('%d'))
In [117]:
daydatye
Out[117]:
11
In [118]:
calcsee.formatday(2016, 1)
Out[118]:
'<td class="tue">2016</td>'
In [120]:
panread = pandas.read_html(calcsee.formatmonth(yrints, mondayfor))
In [121]:
panread[0]
Out[121]:
0 1 2 3 4 5 6
0 2016-10-11 NaT NaT NaT NaT NaT NaT
1 2016-10-17 2016-10-11 2016-10-12 2016-10-13 2016-10-14 2016-10-15 2016-10-16
2 NaT NaT NaT NaT NaT NaT NaT
3 NaT NaT NaT NaT NaT NaT NaT
4 NaT NaT NaT NaT NaT NaT NaT
5 NaT NaT NaT NaT NaT NaT NaT
6 NaT NaT NaT NaT NaT NaT NaT
7 NaT NaT NaT NaT NaT NaT NaT
In [122]:
calcsee.formatmonth(yrints, mondayfor)
Out[122]:
'<table border="0" cellpadding="0" cellspacing="0" class="month">\n<tr><th colspan="7" class="month">October 2016</th></tr>\n<tr><th class="mon">Mon</th><th class="tue">Tue</th><th class="wed">Wed</th><th class="thu">Thu</th><th class="fri">Fri</th><th class="sat">Sat</th><th class="sun">Sun</th></tr>\n<tr><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="sat">1</td><td class="sun">2</td></tr>\n<tr><td class="mon">3</td><td class="tue">4</td><td class="wed">5</td><td class="thu">6</td><td class="fri">7</td><td class="sat">8</td><td class="sun">9</td></tr>\n<tr><td class="mon">10</td><td class="tue">11</td><td class="wed">12</td><td class="thu">13</td><td class="fri">14</td><td class="sat">15</td><td class="sun">16</td></tr>\n<tr><td class="mon">17</td><td class="tue">18</td><td class="wed">19</td><td class="thu">20</td><td class="fri">21</td><td class="sat">22</td><td class="sun">23</td></tr>\n<tr><td class="mon">24</td><td class="tue">25</td><td class="wed">26</td><td class="thu">27</td><td class="fri">28</td><td class="sat">29</td><td class="sun">30</td></tr>\n<tr><td class="mon">31</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td><td class="noday">&nbsp;</td></tr>\n</table>\n'
In [125]:
import os
In [126]:
import random
In [ ]:
 
In [127]:
calcday = calcsee.cssclasses
In [128]:
calcday
Out[128]:
['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
In [129]:
calcfulday = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
In [130]:
len(calcfulday)
Out[130]:
7
In [ ]:
 
In [131]:
random.choice(calcfulday)
Out[131]:
'Friday'
In [132]:
dayweekz
Out[132]:
1
In [133]:
calcfulday[dayweekz]
Out[133]:
'Tuesday'
In [ ]:
 
In [134]:
print(calcday[dayweekz])
tue
In [136]:
random.choice(calcday)
Out[136]:
'tue'
In [ ]:
 
In [137]:
calcsee.firstweekday
Out[137]:
0
In [138]:
calcsee.formatday
Out[138]:
<bound method HTMLCalendar.formatday of <calendar.HTMLCalendar object at 0xaeee90d0>>
In [139]:
calcsee.formatmonth
Out[139]:
<bound method HTMLCalendar.formatmonth of <calendar.HTMLCalendar object at 0xaeee90d0>>
In [140]:
calcsee.
  File "<ipython-input-140-511f2c07e020>", line 1
    calcsee.
            ^
SyntaxError: invalid syntax
In [141]:
passwrdz
Out[141]:
'qwe'
In [142]:
f.encrypt
Out[142]:
<bound method Fernet.encrypt of <cryptography.fernet.Fernet object at 0xaeff4f50>>
In [143]:
token = f.encrypt(passwrdz)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-143-6d6ff1800471> in <module>()
----> 1 token = f.encrypt(passwrdz)

/usr/lib/python3/dist-packages/cryptography/fernet.py in encrypt(self, data)
     58         current_time = int(time.time())
     59         iv = os.urandom(16)
---> 60         return self._encrypt_from_parts(data, current_time, iv)
     61 
     62     def _encrypt_from_parts(self, data, current_time, iv):

/usr/lib/python3/dist-packages/cryptography/fernet.py in _encrypt_from_parts(self, data, current_time, iv)
     62     def _encrypt_from_parts(self, data, current_time, iv):
     63         if not isinstance(data, bytes):
---> 64             raise TypeError("data must be bytes.")
     65 
     66         padder = padding.PKCS7(algorithms.AES.block_size).padder()

TypeError: data must be bytes.
In [144]:
import hashlib
In [145]:
print(hashlib.algorithms_available)
print(hashlib.algorithms_guaranteed)
{'SHA1', 'MD5', 'sha', 'sha1', 'MD4', 'SHA', 'SHA384', 'dsaWithSHA', 'whirlpool', 'sha224', 'md5', 'ripemd160', 'ecdsa-with-SHA1', 'sha512', 'SHA512', 'SHA224', 'SHA256', 'sha256', 'sha384', 'md4', 'DSA-SHA', 'dsaEncryption', 'DSA', 'RIPEMD160'}
{'sha512', 'sha1', 'sha256', 'sha384', 'sha224', 'md5'}
In [146]:
#mystring = input('Enter String to hash: ')
# Assumes the default UTF-8
hash_object = hashlib.sha512(passwrdz.encode())
print(hash_object.hexdigest())
b5ba77af1f7bda735894e746a199acb1d2c836424da2fc46bebb55423dccbff871877a30fab77a31e47b0a29ea0154882e532e9a29b220a8f2958773313bbb2a
In [147]:
print(hash_object.name)
sha512
In [148]:
print(hash_object.block_size)
128
In [149]:
import subprocess
In [ ]:
tempchec = subprocess.check_output(["/opt/vc/bin/vcgencmd", "measure_temp"])
In [ ]:
print(float(tempchec.split(=)[1][:-3]))
In [ ]:
tempchec
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]:
subprocess.check_output(o)
In [ ]:
s = subprocess.check_output([/opt/vc/bin/vcgencmd,measure_temp])
print(float(s.split(=)[1][:-3]))
In [152]:
import socket
socket.gethostbyname(socket.gethostname())
Out[152]:
'127.0.0.1'
In [153]:
socket.gethostname()
Out[153]:
'localhost'
In [154]:
import socket

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('8.8.8.8', 0))  # connecting to a UDP address doesn't send packets
local_ip_address = s.getsockname()[0]
In [155]:
local_ip_address
Out[155]:
'192.168.1.7'
In [156]:
s.getsockname()
Out[156]:
('192.168.1.7', 56084)
In [ ]:
 
In [157]:
socket.gethostbyaddr(socket.gethostname())
Out[157]:
('localhost', ['ip6-localhost', 'ip6-loopback'], ['::1'])
In [160]:
socket.getaddrinfo
Out[160]:
<function socket.getaddrinfo>
In [161]:
subup = subprocess.check_output(['uptime'])
In [162]:
loaspli = subup.split('load average: ')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-162-156caad8bd35> in <module>()
----> 1 loaspli = subup.split('load average: ')

TypeError: Type str doesn't support the buffer API
In [ ]:
 
In [163]:
'''
import os
import subprocess

BAT_PATH = "/proc/acpi/battery/BAT%d"


def get_full_charge(batt_path):
    """Get the max capacity of the battery

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The max capacity of the battery
    :rtype: int
    """
    p1 = subprocess.Popen(["grep",
                            "last full capacity",
                            batt_path + "/info"],
                         stdout=subprocess.PIPE)
    p2 = subprocess.Popen(["awk",
                            "{print $4}"],
                            stdin=p1.stdout,
                            stdout=subprocess.PIPE)
    p1.stdout.close()
    return int(p2.communicate()[0])


def get_current_charge(batt_path):
    """Get the current capacity of the battery

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The current capacity of the battery
    :rtype: int
    """
    p1 = subprocess.Popen(["grep",
                            "remaining capacity",
                            batt_path + "/state"],
                         stdout=subprocess.PIPE)
    p2 = subprocess.Popen(["awk",
                            "{print $3}"],
                            stdin=p1.stdout,
                            stdout=subprocess.PIPE)
    p1.stdout.close()
    return int(p2.communicate()[0])


def guess_battery_path():
    """Gets the path of the battery (BAT0, BAT1...)

    :returns: The path to the battery acpi process information
    :rtype: string
    """
    i = 0
    while True:
        if os.path.exists(BAT_PATH % i):
            return BAT_PATH % i
        i += 1


def is_plugged(batt_path):
    """Returns a flag saying if the battery is plugged in or not

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: A flag, true is plugged, false unplugged
    :rtype: bool
    """
    p = subprocess.Popen(["grep",
                            "charging state",
                            batt_path + "/state"],
                         stdout=subprocess.PIPE)
    return "discharging" not in p.communicate()[0]


def get_battery_percent(batt_path):
    """Calculates the percent of the battery based on the different data of
    the battery processes

    :param batt_path: The dir path to the battery (acpi) processes
    :type batt_path: string
    :returns: The percent translation of the battery total and current capacity
    :rtype: int
    """

    return get_current_charge(batt_path) * 100 / get_full_charge(batt_path)


def main():
    path = guess_battery_path()
    print("Current battery percent: %d" % get_battery_percent(path))
    print("Plugged in" if is_plugged(path) else "Not plugged in")

if __name__ == "__main__":
    main()
'''
Out[163]:
'\nimport os\nimport subprocess\n\nBAT_PATH = "/proc/acpi/battery/BAT%d"\n\n\ndef get_full_charge(batt_path):\n    """Get the max capacity of the battery\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The max capacity of the battery\n    :rtype: int\n    """\n    p1 = subprocess.Popen(["grep",\n                            "last full capacity",\n                            batt_path + "/info"],\n                         stdout=subprocess.PIPE)\n    p2 = subprocess.Popen(["awk",\n                            "{print $4}"],\n                            stdin=p1.stdout,\n                            stdout=subprocess.PIPE)\n    p1.stdout.close()\n    return int(p2.communicate()[0])\n\n\ndef get_current_charge(batt_path):\n    """Get the current capacity of the battery\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The current capacity of the battery\n    :rtype: int\n    """\n    p1 = subprocess.Popen(["grep",\n                            "remaining capacity",\n                            batt_path + "/state"],\n                         stdout=subprocess.PIPE)\n    p2 = subprocess.Popen(["awk",\n                            "{print $3}"],\n                            stdin=p1.stdout,\n                            stdout=subprocess.PIPE)\n    p1.stdout.close()\n    return int(p2.communicate()[0])\n\n\ndef guess_battery_path():\n    """Gets the path of the battery (BAT0, BAT1...)\n\n    :returns: The path to the battery acpi process information\n    :rtype: string\n    """\n    i = 0\n    while True:\n        if os.path.exists(BAT_PATH % i):\n            return BAT_PATH % i\n        i += 1\n\n\ndef is_plugged(batt_path):\n    """Returns a flag saying if the battery is plugged in or not\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: A flag, true is plugged, false unplugged\n    :rtype: bool\n    """\n    p = subprocess.Popen(["grep",\n                            "charging state",\n                            batt_path + "/state"],\n                         stdout=subprocess.PIPE)\n    return "discharging" not in p.communicate()[0]\n\n\ndef get_battery_percent(batt_path):\n    """Calculates the percent of the battery based on the different data of\n    the battery processes\n\n    :param batt_path: The dir path to the battery (acpi) processes\n    :type batt_path: string\n    :returns: The percent translation of the battery total and current capacity\n    :rtype: int\n    """\n\n    return get_current_charge(batt_path) * 100 / get_full_charge(batt_path)\n\n\ndef main():\n    path = guess_battery_path()\n    print("Current battery percent: %d" % get_battery_percent(path))\n    print("Plugged in" if is_plugged(path) else "Not plugged in")\n\nif __name__ == "__main__":\n    main()\n'
In [ ]:
 s = subprocess.check_output([uptime])
    load_split = s.split(load average: )
    load_five = float(load_split[1].split(,)[1])
    up = load_split[0]
    up_pos = up.rfind(,,0,len(up)-4)
    up = up[:up_pos].split(up )[1]
    return ( up , load_five )
In [165]:
'''
import subprocess
import os
    
def get_ram():
    “Returns a tuple (total ram, available ram) in megabytes. See www.linuxatemyram.com”
    try:
        s = subprocess.check_output([“free”,”-m”])
        lines = s.split(‘\n’)
        return ( int(lines[1].split()[1]), int(lines[2].split()[3]) )
    except:
        return 0def get_process_count():
        “Returns the number of processes”
    try:
        s = subprocess.check_output([“ps”,”-e”])
        return len(s.split(‘\n’))
    except:
        return 0def get_up_stats():
    “Returns a tuple (uptime, 5 min load average)”
    try:
    s = subprocess.check_output([“uptime”])
    load_split = s.split(‘load average: ‘)
    load_five = float(load_split[1].split(‘,’)[1])
    up = load_split[0]
    up_pos = up.rfind(‘,’,0,len(up)-4)
    up = up[:up_pos].split(‘up ‘)[1]
    return ( up , load_five )
    except:
    return ( ” , 0 )def get_connections():
    “Returns the number of network connections”
    try:
    s = subprocess.check_output([“netstat”,”-tun”])
    return len([x for x in s.split() if x == ‘ESTABLISHED’])
    except:
    return 0def get_temperature():
    “Returns the temperature in degrees C”
    try:
    s = subprocess.check_output([“/opt/vc/bin/vcgencmd”,”measure_temp”])
    return float(s.split(‘=’)[1][:-3])
    except:
    return 0def get_ipaddress():
    “Returns the current IP address”
    arg=’ip route list’
    p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)
    data = p.communicate()
    split_data = data[0].split()
    ipaddr = split_data[split_data.index(‘src’)+1]
    return ipaddr

    def get_cpu_speed():
    “Returns the current CPU speed”
    f = os.popen(‘/opt/vc/bin/vcgencmd get_config arm_freq’)
    cpu = f.read()
    return cpu

    print ‘Free RAM: ‘+str(get_ram()[1])+’ (‘+str(get_ram()[0])+’)’
    print ‘Nr. of processes: ‘+str(get_process_count())
    print ‘Up time: ‘+get_up_stats()[0]
    print ‘Nr. of connections: ‘+str(get_connections())
    print ‘Temperature in C: ‘ +str(get_temperature())
    print ‘IP-address: ‘+get_ipaddress()
    print ‘CPU speed: ‘+str(get_cpu_speed())
'''
Out[165]:
'\nimport subprocess\nimport os\n    \ndef get_ram():\n    “Returns a tuple (total ram, available ram) in megabytes. See www.linuxatemyram.com”\n    try:\n        s = subprocess.check_output([“free”,”-m”])\n        lines = s.split(‘\n’)\n        return ( int(lines[1].split()[1]), int(lines[2].split()[3]) )\n    except:\n        return 0def get_process_count():\n        “Returns the number of processes”\n    try:\n        s = subprocess.check_output([“ps”,”-e”])\n        return len(s.split(‘\n’))\n    except:\n        return 0def get_up_stats():\n    “Returns a tuple (uptime, 5 min load average)”\n    try:\n    s = subprocess.check_output([“uptime”])\n    load_split = s.split(‘load average: ‘)\n    load_five = float(load_split[1].split(‘,’)[1])\n    up = load_split[0]\n    up_pos = up.rfind(‘,’,0,len(up)-4)\n    up = up[:up_pos].split(‘up ‘)[1]\n    return ( up , load_five )\n    except:\n    return ( ” , 0 )def get_connections():\n    “Returns the number of network connections”\n    try:\n    s = subprocess.check_output([“netstat”,”-tun”])\n    return len([x for x in s.split() if x == ‘ESTABLISHED’])\n    except:\n    return 0def get_temperature():\n    “Returns the temperature in degrees C”\n    try:\n    s = subprocess.check_output([“/opt/vc/bin/vcgencmd”,”measure_temp”])\n    return float(s.split(‘=’)[1][:-3])\n    except:\n    return 0def get_ipaddress():\n    “Returns the current IP address”\n    arg=’ip route list’\n    p=subprocess.Popen(arg,shell=True,stdout=subprocess.PIPE)\n    data = p.communicate()\n    split_data = data[0].split()\n    ipaddr = split_data[split_data.index(‘src’)+1]\n    return ipaddr\n\n    def get_cpu_speed():\n    “Returns the current CPU speed”\n    f = os.popen(‘/opt/vc/bin/vcgencmd get_config arm_freq’)\n    cpu = f.read()\n    return cpu\n\n    print ‘Free RAM: ‘+str(get_ram()[1])+’ (‘+str(get_ram()[0])+’)’\n    print ‘Nr. of processes: ‘+str(get_process_count())\n    print ‘Up time: ‘+get_up_stats()[0]\n    print ‘Nr. of connections: ‘+str(get_connections())\n    print ‘Temperature in C: ‘ +str(get_temperature())\n    print ‘IP-address: ‘+get_ipaddress()\n    print ‘CPU speed: ‘+str(get_cpu_speed())\n'
In [ ]:
#import ConfigParser

config = configparser.RawConfigParser()

# When adding sections or items, add them in the reverse order of
# how you want them to be displayed in the actual file.
# In addition, please note that using RawConfigParser's and the raw
# mode of ConfigParser's respective set functions, you can assign
# non-string values to keys internally, but will receive an error
# when attempting to write to a file or when you get it in non-raw
# mode. SafeConfigParser does not allow such assignments to take place.

config.add_section('userinfo')
config.set('userinfo', 'username', myusr)

config.set('userinfo', 'password', (hash_object.hexdigest()))
config.add_section('tempsetting')
config.set('tempsetting', 'drivertemphigh', sethightemp)
config.set('tempsetting', 'drivertemplow', setlowtemp)
config.set('tempsetting', 'passtemphigh', sethightemp)
config.set('tempsetting', 'passtemplow', setlowtemp)


config.add_section('dooropenstatus')

#config.set('doorstatus', 'drifronop', )
config.set('dooropenstatus', 'driversfront', dfstat)

config.set('dooropenstatus', 'passfront', pfstat)

config.set('dooropenstatus', 'passrear', prstat)

config.set('dooropenstatus', 'driversrear', drstat)

config.add_section('doorlockstatus')

config.set('doorlockstatus', 'driversfont', opddor)

config.set('doorlockstatus', 'passfront', opddor)

config.set('doorlockstatus', 'passrear', opddor)

config.set('doorlockstatus', 'driverrear', opddor)

config.add_section('chargestatus')

config.set('chargestatus', 'charging', 'complete')

config.set('chargestatus', "battcurrent", flsecur)

config.set('chargestatus', 'chargvolt', 2.5)

config.set('chargestatus', 'timecharge', 60)
#config.set('charges')

#Set Valet Mode
config.add_section('valetmode')

config.set('valetmode', 'valeton', valeton)

config.set('valetmode', 'timenow', (timnow))

config.set('valetmode', 'traveltime', 40)

config.set('valetmode', 'dayname', calcfulday[dayweekz])

config.set('valetmode', 'timehuman', timnow.humanize())

#config.set('templow', 'an_int', setlowtemp)
#config.set('drivefront', 'an_int', '3')
#config.set('passfront', 'baz', 'fun')
#config.set('passback', 'bar', 'Python')
#config.set('driveback', 'foo', '%(bar)s is %(baz)s!')

# Writing our configuration file to 'example.cfg'
with open('tesla.cfg', 'w') as configfile:
    config.write(configfile)
In [ ]:
crea = config.read
In [ ]:
with open('tesla.cfg', 'r') as configfile:
    print(config.read(configfile))
In [ ]:
temphi = 32
templo = 17

tempstr = ("{'temphi' :  " + str(temphi) + '}')
In [ ]:
templow = ("{'templow' :  " + str(templo) + '}')
In [ ]:
templow

{ "response": { "gui_distance_units": "mi/hr", "gui_temperature_units": "F", "gui_charge_rate_units": "mi/hr", "gui_24_hour_time": false, "gui_range_display": "Rated" } }tempstr

{ "response": { "charging_state": "Complete", // "Charging", ?? "charge_to_max_range": false, // current std/max-range setting "max_range_charge_counter": 0, "fast_charger_present": false, // connected to Supercharger? "battery_range": 239.02, // rated miles "est_battery_range": 155.79, // range estimated from recent driving "ideal_battery_range": 275.09, // ideal miles "battery_level": 91, // integer charge percentage "battery_current": -0.6, // current flowing into battery "charge_starting_range": null, "charge_starting_soc": null, "charger_voltage": 0, // only has value while charging "charger_pilot_current": 40, // max current allowed by charger & adapter "charger_actual_current": 0, // current actually being drawn "charger_power": 0, // kW (rounded down) of charger "time_to_full_charge": null, // valid only while charging "charge_rate": -1.0, // float mi/hr charging or -1 if not charging "charge_port_door_open": true } }

https://owner-api.teslamotors.com/api/1/vehicles/1/command/set_temps?driver_temp=23.7&passenger_temp=18.1

Returns the current temperature and climate control state.

var TEMP_HI = 32; var TEMP_LO = 17; function set_temperature( params, cb ) { var dtemp = params.dtemp; var ptemp = params.ptemp; var vid = params.id; var error = false;

//var temp_str = "";
if ( dtemp !== undefined && dtemp <= TEMP_HI && dtemp >= TEMP_LO) {
    //temp_str = 'driver_temp=' + dtemp; // change from string to JSON form data
} else {
    error = true;
}
// if no passenger temp is passed, the driver temp is also used as the passenger temp
if ( ptemp !== undefined && ptemp <= TEMP_HI && ptemp >= TEMP_LO) {
    //temp_str = temp_str +'&passenger_temp=' + ptemp; // change from string to JSON form data
} else if ( ptemp === undefined ) {
    ptemp = dtemp;
} else {
    error = true;
}
if (!error) {
    request( {
        method: 'POST',
        url: portal + '/vehicles/' + vid + '/command/set_temps',
        gzip: true,
        headers: http_header,
        form: {
            "driver_temp" : dtemp.toString(),
            "passenger_temp" : ptemp.toString(),
        }
    }, function (error, response, body) { 
        if ((!!error) || (response.statusCode !== 200)) return report(error, response, body, cb);
        try {
            var data = JSON.parse(body); 
            if (typeof cb == 'function') return cb( data.response );  
            else return true;
        } catch (err) {
            return report2('set_temps', body, cb);
        }
    });
} else {
    if (typeof cb == 'function') return cb( new Error('Invalid temperature setting (' + dtemp + 'C), Passenger (' + ptemp + 'C)'));  
    else return false;
}

} exports.set_temperature = set_temperature; exports.TEMP_HI = TEMP_HI; exports.TEMP_LO = TEMP_LO;

{ "response": { "df": false, // driver's side front door open "dr": false, // driver's side rear door open "pf": false, // passenger's side front door open "pr": false, // passenger's side rear door open "ft": false, // front trunk is open "rt": false, // rear trunk is open "car_verson": "1.19.42", // car firmware version "locked": true, // car is locked "sun_roof_installed": false, // panoramic roof is installed "sun_roof_state": "unknown", "sun_roof_percent_open": 0, // null if not installed "dark_rims": false, // gray rims installed "wheel_type": "Base19", // wheel type installed "has_spoiler": false, // spoiler is installed "roof_color": "Colored", // "None" for panoramic roof "perf_config": "Base" } }

{ "response": { "charging_state": "Complete", // "Charging", ?? "charge_to_max_range": false, // current std/max-range setting "max_range_charge_counter": 0, "fast_charger_present": false, // connected to Supercharger? "battery_range": 239.02, // rated miles "est_battery_range": 155.79, // range estimated from recent driving "ideal_battery_range": 275.09, // ideal miles "battery_level": 91, // integer charge percentage "battery_current": -0.6, // current flowing into battery "charge_starting_range": null, "charge_starting_soc": null, "charger_voltage": 0, // only has value while charging "charger_pilot_current": 40, // max current allowed by charger & adapter "charger_actual_current": 0, // current actually being drawn "charger_power": 0, // kW (rounded down) of charger "time_to_full_charge": null, // valid only while charging "charge_rate": -1.0, // float mi/hr charging or -1 if not charging "charge_port_door_open": true } }

More car info

What music is being played.

Is my car unlocked? Unlock when device within certain distance.

Checks that all the doors are shut

https://owner-api.teslamotors.com/api/1/vehicles/vehicle_id/command/door_unlock

https://owner-api.teslamotors.com/api/1/vehicles/vehicle_id/command/door_lock

In [166]:
for doorq in doorquen:
    if doorq == True:
        print('Warning Door Open')
In [167]:
for doorq in doorquen:
    #print(doorq)
    if doorq == False:
        #for inz in range():
        print('Warning Door Close')
Warning Door Close
Warning Door Close
Warning Door Close
Warning Door Close
In [ ]:
 
In [168]:
mydict['response']['dr']
Out[168]:
False
In [169]:
mydict['response']['pf']
Out[169]:
False
In [170]:
mydict['response']['pr']
Out[170]:
False
In [172]:
def testdoorlock():
    assert mydict['response']['locked'] == 'True'
    
def testdoorunlock():
    assert mydict['response']['locked'] == 'False'
In [ ]:
 
In [173]:
mydict['response']['locked']
Out[173]:
True
In [174]:
mydict['response']['df']
Out[174]:
False
In [ ]:
 
In [175]:
mydict['response']['dr']
Out[175]:
False
In [176]:
mydict['response']['pf']
Out[176]:
False
In [177]:
mydict['response']['pr']
Out[177]:
False
In [178]:
vechj = open('/home/wcm/git/vech.json', 'r')
In [179]:
rdvechj = vechj.read()
In [180]:
rdvechj
Out[180]:
'{\n  "response": [\n    {\n      "color": null,\n      "display_name": null,\n      "id": 321,\n      "option_codes": "MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013",\n      "user_id": 123,\n      "vehicle_id": 1234567890,\n      "vin": "5YJSA1CN5CFP01657",\n      "tokens": [\n        "x",\n        "x"\n      ],\n      "state": "online"\n    }\n  ],\n  "count": 1\n}\n'
In [181]:
json.loads(rdvechj)
Out[181]:
{'count': 1,
 'response': [{'color': None,
   'display_name': None,
   'id': 321,
   'option_codes': 'MS01,RENA,TM00,DRLH,PF00,BT85,PBCW,RFPO,WT19,IBMB,IDPB,TR00,SU01,SC01,TP01,AU01,CH00,HP00,PA00,PS00,AD02,X020,X025,X001,X003,X007,X011,X013',
   'state': 'online',
   'tokens': ['x', 'x'],
   'user_id': 123,
   'vehicle_id': 1234567890,
   'vin': '5YJSA1CN5CFP01657'}]}

fuuslack

fuuslack

useless crap slack stuff.

Send messages to both Slack and Twitter.

Would like to add messages i reply and responces but don't want to get in trouble with organisers.

In [3]:
import slacker

from TwitterFollowBot import TwitterBot

import getpass
In [7]:
myusr = getpass.getuser()
In [ ]:
 
In [8]:
my_bot = TwitterBot('/home/' + myusr + '/config.txt')
In [ ]:
 
In [9]:
opslkey = open('/home/' + myusr + '/Downloads/slacker.txt', 'r')
In [10]:
rdops = opslkey.read()
In [11]:
stslack = rdops.strip('\n')
In [12]:
slack = slacker.Slacker(stslack)

# Send a message to #general channel

# Get users list
response = slack.users.list()
users = response.body['members']
In [13]:
lusr = len(users)
In [14]:
lusr
Out[14]:
38
In [15]:
slms = slack.search.messages('irc')
In [16]:
matlens = len(slms.body['messages']['matches'])
In [17]:
matlens
Out[17]:
16
In [18]:
for mlen in range(0, matlens):
    print(mlen)
    print((slms.body['messages']['matches'][mlen]['previous']['text'][0:90]))
    print((slms.body['messages']['matches'][mlen]['previous']['username']))
    #Got in trouble for tweeting others slack messages so disabling this and just 
    #using 
    #input to send messages to both slack and twitter. 
    #my_bot.send_tweet(slms.body['messages']['matches'][mlen]['previous']['username'] + ': ' + (slms.body['messages']['matches'][mlen]['previous']['text'][0:90]) + ' #lca2016')

    print((slms.body['messages']['matches'][mlen]['text'][0:90]))
    print((slms.body['messages']['matches'][mlen]['username']))



    print((slms.body['messages']['matches'][mlen]['next']['text'][0:120]))
    print((slms.body['messages']['matches'][mlen]['next']['username']))
    #my_bot.send_tweet((slms.body['messages']['matches'][mlen]['username']) + ': ' + )
0
is everywhere
kathyreid
I thought it was one of those split brain things like IRC
brong
one kathyreid doesn't know what the other one knows
brong
1
it's an interesting mix, I must say
dtbell91
A brief comment on security of gateways to xmpp and irc.
Irc supports ssl so the server to
dns
johndalton: but can you speak fluent RFC 7162?
brong
2
kicks <@U0JT16M63|dtbell91> from the channel
mattcen
fine, I'll go back to IRC. they didn't kick me :stuck_out_tongue:
dtbell91
to be fair, there ~is~ a sign on your back…
itgrrl
3
I think it’s not the worst thing to let the Slack and IRC groups self-form. People might f
tennessee
well currently the IRC channel is 90% complaints about the slack UX :stuck_out_tongue:
gm
And the slack channel is comments about IRC and IRC/XMPP client integration.
mattcen
4
For now, I'm not enabling it.
itgrrl
i’m surprised that slack even allows plaintext IRC connections...
gm
<@U0JT16M63>: I'm still upset that the rego wouldn't let me have my favourite shell set as PowerShell.
ctudball
5
<@U0JT16M63>: Yes. I don't understand the security implications of either yet.
itgrrl
gateway sounds like it allows one person to connect over another technology (XMPP or IRC) 
dtbell91
dtbell91: Yes, two different thing.
evmcl
6
I'm sure others see the inability to do those things in IRC as a feature.  :-)  We all hav
itgrrl
Would it be possible to turn the IRC gateway on, if it isn’t already? :simple_smile:
parisba
I like to use Slack from my IRC client (and disregard all the arguments :wink:
parisba
7
Probably on Facebook  ;-)
itgrrl
<@U0B0TGGS2>: Sorry, I was referring to the IRC gateway to access Slack (instead of the XM
evmcl
I hope this works, I do enjoy using Slack personally ¯\_(ツ)_/¯
dtbell91
8
<@U0K0K1RMX>: I have no involvement in the running of the IRC channel so can't comment on 
itgrrl
heh, just checked the wiki… apparently we have a facebook page? and nobody complained abou
gm
<@U0K0JM96V>: lol
itgrrl
9
as for the specific complaints about “it’s not FOSS”, i think the wider community’s views 
gm
Okay, fair enough. I assume that's the same for the IRC gateway, which would have been my 
evmcl
<@U0K0JM96V>: I don't really buy it when ppl make that argument—the 'conversation' and info is already split between IRC
itgrrl
10
hello!
msmarymac
re the IRC bridging above, it might be worth discussing
gm
Hey <@U0B0TGGS2>, thanks for setting this up. Any chance of turning on the XMPP gateway? Then I could use Pidgin which h
evmcl
11
Hi all!
<@U0B0TGGS2>, thanks for the invite!
a.kuplev
croy: a bouncer is basically something that you leave logged in to IRC permanently, even w
yjmbo
oh right
croy
12
reads the email thread... hah
brong
FastMail moved from IRC to slack recently (we still run some ops stuff in IRC, so I have t
brong
followed by a decent mobile experience that doesn't fricking ding every time you change networks like andchat used to
brong
13
it's worth reminding everyone, just because this isn't an 'official' conference Slack, the
dtbell91
much the same as it applies on IRC, Twitter, email, etc when in relation to conference eve
dtbell91
Yes, thanks David. Good reminder.
itgrrl
14
<@U0B0TGGS2>: and/or slackin for auto-inviting people? <https://github.com/rauchg/slackin>
glasnt
I'll take a look at slackin when I get a chance. Not sure IRC mirroring is a good idea in 
itgrrl
of course VLine do free travel when I take annual leave... after all the complaining and "feedback" I've provided them o
dtbell91
15
w00t!
itgrrl
I don’t know why I prefer Slack to IRC, but I just do.
tennessee
I think I’m going to be arriving midway through Monday, trying to work out if it makes sense to arrive midway through a 
tennessee
In [172]:
(slms.body['messages']['matches'][0]['next']['text'])
Out[172]:
"followed by a decent mobile experience that doesn't fricking ding every time you change networks like andchat used to"
In [173]:
schli = slack.channels.list()
In [174]:
for slchan in range(0, len(schli.body['channels'])):
    print(slchan)
    print(schli.body['channels'][slchan]['name'])
0
_newbies
1
bofs
2
general
3
random
4
transport
In [22]:
poswhat = input('What to post: ')
What to post: Hopefully this is sent to both slack and twitter.
In [23]:
slack.chat.post_message('#general', poswhat, as_user=True)
Out[23]:
<slacker.Response at 0xb20321d0>
In [24]:
my_bot.send_tweet(poswhat + ' #lca16')
Out[24]:
{'contributors': None,
 'coordinates': None,
 'created_at': 'Thu Jan 21 11:58:19 +0000 2016',
 'entities': {'hashtags': [{'indices': [50, 56], 'text': 'lca16'}],
  'symbols': [],
  'urls': [],
  'user_mentions': []},
 'favorite_count': 0,
 'favorited': False,
 'geo': None,
 'id': 690141371856982016,
 'id_str': '690141371856982016',
 'in_reply_to_screen_name': None,
 'in_reply_to_status_id': None,
 'in_reply_to_status_id_str': None,
 'in_reply_to_user_id': None,
 'in_reply_to_user_id_str': None,
 'is_quote_status': False,
 'lang': 'en',
 'place': None,
 'retweet_count': 0,
 'retweeted': False,
 'source': '<a href="http://wcmckee.com" rel="nofollow">wcmtwet</a>',
 'text': 'Hopefully this is sent to both slack and twitter. #lca16',
 'truncated': False,
 'user': {'contributors_enabled': False,
  'created_at': 'Sat Sep 20 08:09:39 +0000 2014',
  'default_profile': False,
  'default_profile_image': False,
  'description': 'Open Source Python Software/Web Development. AV volunteer at tech confs, and writer.',
  'entities': {'description': {'urls': []},
   'url': {'urls': [{'display_url': 'wcmckee.com',
      'expanded_url': 'http://wcmckee.com',
      'indices': [0, 23],
      'url': 'https://t.co/KQYI4xVTZd'}]}},
  'favourites_count': 3512,
  'follow_request_sent': False,
  'followers_count': 936,
  'following': False,
  'friends_count': 872,
  'geo_enabled': True,
  'has_extended_profile': True,
  'id': 2821347210,
  'id_str': '2821347210',
  'is_translation_enabled': False,
  'is_translator': False,
  'lang': 'en',
  'listed_count': 772,
  'location': 'Hamilton City, New Zealand',
  'name': 'wcmckee',
  'notifications': False,
  'profile_background_color': '000000',
  'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png',
  'profile_background_tile': False,
  'profile_banner_url': 'https://pbs.twimg.com/profile_banners/2821347210/1442397712',
  'profile_image_url': 'http://pbs.twimg.com/profile_images/621211385746161664/tGchJstD_normal.jpg',
  'profile_image_url_https': 'https://pbs.twimg.com/profile_images/621211385746161664/tGchJstD_normal.jpg',
  'profile_link_color': 'FFCC4D',
  'profile_sidebar_border_color': '000000',
  'profile_sidebar_fill_color': '000000',
  'profile_text_color': '000000',
  'profile_use_background_image': False,
  'protected': False,
  'screen_name': 'wcmckeedotcom',
  'statuses_count': 23260,
  'time_zone': 'Wellington',
  'url': 'https://t.co/KQYI4xVTZd',
  'utc_offset': 46800,
  'verified': False}}

gif-pokmon

gif pokmon

script to explore the pokemon api and get gifs.

In [42]:
import requests
import json
import shutil
In [29]:
reqg = requests.get('http://pokeapi.co/api/v1/pokedex/1/')
In [30]:
retxt = reqg.text
In [31]:
pokload = json.loads(retxt)
In [32]:
allpok = len(pokload['pokemon'])
In [36]:
print(pokload['pokemon'][200])
{'name': 'houndour', 'resource_uri': 'api/v1/pokemon/228/'}
In [37]:
allpok
Out[37]:
778
In [ ]:
opwritj = requests.get('http://api.giphy.com/v1/gifs/search?q=' + (pokload['pokemon'][alpo]['name']) + '&api_key=dc6zaTOxFJmzC')
In [43]:
for alpo in range(allpok):
    print(pokload['pokemon'][alpo]['name'])
    opwritj = requests.get('http://api.giphy.com/v1/gifs/search?q=' + (pokload['pokemon'][alpo]['name']) + '&api_key=dc6zaTOxFJmzC')
    wrijrd = opwritj.text
    jswri = json.loads(wrijrd)
    jswln = len(jswri['data'])
    for jsw in range(0, jswln):
        if '.gif' in jswri['data'][jsw]['images']['downsized']['url']:
            print(jswri['data'][jsw]['images']['downsized']['url'])
            response = requests.get((jswri['data'][jsw]['images']['downsized']['url']), stream=True)
            with open('/home/wcmckee/Downloads/gify/' + (pokload['pokemon'][alpo]['name']) + str(jsw) + '.gif', 'wb') as out_file:
                shutil.copyfileobj(response.raw, out_file)
                del response
rattata
http://media1.giphy.com/media/vXkfATtZmC26Q/giphy.gif
http://media0.giphy.com/media/IrMkKlhZy4hri/giphy.gif
http://media4.giphy.com/media/jeWqeTeBS03WE/giphy.gif
http://media3.giphy.com/media/NN4fvJBKKvrnq/giphy.gif
http://media2.giphy.com/media/A3LyV2yV5r5cI/giphy.gif
http://media1.giphy.com/media/6obZXFnopj9vy/giphy.gif
http://media4.giphy.com/media/CZgC0EiQhwiM8/giphy.gif
http://media2.giphy.com/media/10oCqxckv42wlq/giphy.gif
http://media4.giphy.com/media/OZnzDqIzdduuY/giphy.gif
charmander
http://media2.giphy.com/media/PiiQ5B1XxxiX6/giphy.gif
http://media3.giphy.com/media/V4sY8JCTxGyaI/giphy.gif
http://media1.giphy.com/media/fJXClS1SskWPu/giphy.gif
http://media2.giphy.com/media/11agp3tD5MPgnC/giphy.gif
http://media2.giphy.com/media/hEpqDK5fSGeqc/giphy.gif
http://media2.giphy.com/media/6JvWR1rDbseeQ/giphy.gif
http://media0.giphy.com/media/EUge7PKTnkwzm/giphy.gif
http://media1.giphy.com/media/Lk3CyavFIcr2o/giphy.gif
http://media1.giphy.com/media/u1k1kpDZSw5sA/giphy.gif
http://media.giphy.com/media/YmAqCTTOLHh0A/giphy-tumblr.gif
http://media4.giphy.com/media/WJ7Tr9wi8xVe0/giphy.gif
http://media2.giphy.com/media/kyQZBTnF1fG2A/giphy.gif
http://media.giphy.com/media/3lttbqFYuaKsM/giphy-tumblr.gif
http://media1.giphy.com/media/d8erhw94dHRsI/giphy.gif
http://media.giphy.com/media/2Faz6MZP8J3zpcXBe/giphy-tumblr.gif
http://media2.giphy.com/media/zggFOBuDFySDm/giphy.gif
http://media3.giphy.com/media/7YmRxmyA3QA3C/giphy.gif
http://media4.giphy.com/media/vz5JEg2WIJ8hG/giphy.gif
http://media1.giphy.com/media/OTr3AVq8Pm2XK/giphy.gif
http://media3.giphy.com/media/C5BvJRoI0ONs4/giphy.gif
http://media2.giphy.com/media/4vGhTk9nDMnug/giphy.gif
http://media4.giphy.com/media/gdh0jRFilcn4Y/giphy.gif
http://media4.giphy.com/media/4MwcPSlM8j3IA/giphy.gif
http://media3.giphy.com/media/d4yP1krJcfdCM/giphy.gif
http://media4.giphy.com/media/bLiebL9q4RMK4/giphy.gif
charmeleon
http://media2.giphy.com/media/R0fZ5K1BspBjW/giphy.gif
http://media1.giphy.com/media/u1k1kpDZSw5sA/giphy.gif
http://media1.giphy.com/media/3r3bSqctriays/giphy.gif
http://media3.giphy.com/media/7YmRxmyA3QA3C/giphy.gif
http://media4.giphy.com/media/vz5JEg2WIJ8hG/giphy.gif
http://media3.giphy.com/media/C5BvJRoI0ONs4/giphy.gif
http://media1.giphy.com/media/OTr3AVq8Pm2XK/giphy.gif
http://media4.giphy.com/media/4FPCEiIGk41cQ/giphy.gif
http://media4.giphy.com/media/tyoOzh4nA1Fao/giphy.gif
http://media0.giphy.com/media/Gccz9v9BmGHtu/giphy.gif
http://media1.giphy.com/media/2LqbHgd5gwgO4/giphy.gif
http://media4.giphy.com/media/cYmRQxMLaK9gI/giphy.gif
http://media4.giphy.com/media/wCnNTsp817oY0/giphy.gif
http://media1.giphy.com/media/POGOvsLHgXmpi/giphy.gif
http://media1.giphy.com/media/OKG0r9IgZ11ba/giphy.gif
http://media2.giphy.com/media/oecPcKjruvytG/giphy.gif
http://media3.giphy.com/media/d4yP1krJcfdCM/giphy.gif
http://media4.giphy.com/media/bLiebL9q4RMK4/giphy.gif
http://media4.giphy.com/media/p25VnssgQTo4w/giphy.gif
http://media1.giphy.com/media/IlzWt9twEUeSQ/giphy.gif
http://media3.giphy.com/media/BM1w3GRjpTrk4/giphy.gif
http://media4.giphy.com/media/BRwmhn51DJh8A/giphy.gif
http://media3.giphy.com/media/DhIHKaOKB5pUA/giphy.gif
http://media4.giphy.com/media/nBHnyQePKnES4/giphy.gif
http://media3.giphy.com/media/tTsyn0reTC3rG/giphy.gif
wartortle
http://media3.giphy.com/media/APUf2KTVPMUo/giphy.gif
http://media3.giphy.com/media/13RuvX8oKp701G/giphy.gif
http://media1.giphy.com/media/EhTwMHUJMrc7m/giphy.gif
http://media2.giphy.com/media/MZpmFL1wqh60g/giphy.gif
http://media4.giphy.com/media/GVHKUACqw8480/giphy.gif
http://media3.giphy.com/media/cHmJaZS0vw4Ny/giphy.gif
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-43-1f5c2d9799f0> in <module>()
     10             response = requests.get((jswri['data'][jsw]['images']['downsized']['url']), stream=True)
     11             with open('/home/wcmckee/Downloads/gify/' + (pokload['pokemon'][alpo]['name']) + str(jsw) + '.gif', 'wb') as out_file:
---> 12                 shutil.copyfileobj(response.raw, out_file)
     13                 del response

/usr/lib/python3.4/shutil.py in copyfileobj(fsrc, fdst, length)
     64     """copy data from file-like object fsrc to file-like object fdst"""
     65     while 1:
---> 66         buf = fsrc.read(length)
     67         if not buf:
     68             break

/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/response.py in read(self, amt, decode_content, cache_content)
    172             else:
    173                 cache_content = False
--> 174                 data = self._fp.read(amt)
    175                 if amt != 0 and not data:  # Platform-specific: Buggy versions of Python.
    176                     # Close the connection when no data is returned

/usr/lib/python3.4/http/client.py in read(self, amt)
    498             # Amount is given, so call base class version
    499             # (which is implemented in terms of self.readinto)
--> 500             return super(HTTPResponse, self).read(amt)
    501         else:
    502             # Amount is not given (unbounded read) so we must check self.length

/usr/lib/python3.4/http/client.py in readinto(self, b)
    537         # connection, and the user is reading more bytes than will be provided
    538         # (for example, reading in 1k chunks)
--> 539         n = self.fp.readinto(b)
    540         if not n and b:
    541             # Ideally, we would raise IncompleteRead if the content-length

/usr/lib/python3.4/socket.py in readinto(self, b)
    369         while True:
    370             try:
--> 371                 return self._sock.recv_into(b)
    372             except timeout:
    373                 self._timeout_occurred = True

KeyboardInterrupt: 

nzpostaddy

nzpostaddy

yay maps, something I haven't really used before. Good to try something new.

Using some demo examples from nz post. Examples are printed below.

script to search for addresses.

Gets address from nzpost then displays static map from mapquestapi

In [1]:
import json
import shutil
import requests
In [2]:
opjsres = open('/home/wcmckee/github/nzpostad.json', 'r')
In [3]:
opjrd = opjsres.read()
In [4]:
nzpod = json.loads(opjrd)
In [5]:
nzpod
Out[5]:
{'addresses': [{'address_id': '196111',
   'dpid': '754977',
   'full_address': '19 Queen Alexandra Street, Lansdowne, Masterton 5810'},
  {'address_id': '197147',
   'dpid': '750361',
   'full_address': '23 Queen Alexandra Street, Lansdowne, Masterton 5810'},
  {'address_id': '195925',
   'dpid': '751485',
   'full_address': '7A Queen Alexandra Street, Lansdowne, Masterton 5810'},
  {'address_id': '198893',
   'dpid': '747422',
   'full_address': '8 Queen Alexandra Street, Lansdowne, Masterton 5810'},
  {'address_id': '195986',
   'dpid': '754969',
   'full_address': '9A Queen Alexandra Street, Lansdowne, Masterton 5810'}],
 'success': True}
In [6]:
nzpaddy = nzpod['addresses']
In [7]:
nzplen = len(nzpod['addresses'])
In [8]:
nzplen
Out[8]:
5
In [9]:
for nzp in range(0, nzplen):
    nzitm = (nzpaddy[nzp])
    print(nzitm['full_address'])
19 Queen Alexandra Street, Lansdowne, Masterton 5810
23 Queen Alexandra Street, Lansdowne, Masterton 5810
7A Queen Alexandra Street, Lansdowne, Masterton 5810
8 Queen Alexandra Street, Lansdowne, Masterton 5810
9A Queen Alexandra Street, Lansdowne, Masterton 5810
In [10]:
opsuccessad = open('/home/wcmckee/github/nzpostsuccess.json', 'r')
In [11]:
opsucrd = opsuccessad.read()
In [12]:
opjslo = json.loads(opsucrd)
In [13]:
opjslo
Out[13]:
{'address': {'city': 'Dunedin',
  'country': 'New Zealand',
  'depot_name': 'Dunedin Depot',
  'is_rural_delivery': False,
  'latitude': -45.9041,
  'longitude': 170.552,
  'postcode': '9013',
  'run_number': 'DCP025  ',
  'street': 'Oregon',
  'street_number': 71,
  'street_type': 'Street',
  'suburb': 'Ocean Grove'},
 'message_id': '618a5799-85e3-4559-8a62-280f231a26b3',
 'success': True}
In [14]:
opja = opjslo['address']
In [15]:
opja
Out[15]:
{'city': 'Dunedin',
 'country': 'New Zealand',
 'depot_name': 'Dunedin Depot',
 'is_rural_delivery': False,
 'latitude': -45.9041,
 'longitude': 170.552,
 'postcode': '9013',
 'run_number': 'DCP025  ',
 'street': 'Oregon',
 'street_number': 71,
 'street_type': 'Street',
 'suburb': 'Ocean Grove'}
In [16]:
latad = opja['latitude']
In [17]:
longad = opja['longitude']
In [18]:
latad
Out[18]:
-45.9041
In [19]:
longad
Out[19]:
170.552
In [ ]:
mapk = open('/home/wcmckee/github/mapkey.txt', 'r')
In [ ]:
mapkrd = mapk.read()
In [ ]:
reqimg = 'http://www.mapquestapi.com/staticmap/v4/getmap?key=' + mapkrd + '&size=400,200&zoom=10&center=' + str(latad) + ',' + str(longad) 
In [ ]:
rmnz = reqimg.replace('\n', '')
In [ ]:
response = requests.get(rmnz, stream=True)
with open('img.png', 'wb') as out_file:
    shutil.copyfileobj(response.raw, out_file)
del response