tag:blogger.com,1999:blog-9538706608185254032024-02-08T07:22:54.569+05:30Discussion and Programming in C and PythonAnonymoushttp://www.blogger.com/profile/05035455583114965257noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-953870660818525403.post-39621432940427230242015-05-05T18:38:00.002+05:302015-05-05T19:16:23.844+05:30INSTALL PYTHON AND PYGAME IN WINDOWS 7<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="font-family: Courier New, Courier, monospace; font-size: 20px;"><b>1. If your pygame or python is not working; take a look at the below tutorial first. If you feel like you have not installed python or pygame properly; then uninstall them and follow the below instructions.</b></span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace; font-size: 20px;"><b>2. If you have not installed Python yet; go to <a href="https://www.python.org/downloads/" target="_blank"><span style="color: red;">PYTHON DOWNLOADS</span></a> and download the latest version of Python-2 or Python-3 and install it.</b></span><br />
<div>
<span style="color: #6aa84f; font-family: Courier New, Courier, monospace; font-size: 20px;"><b>Note: The latest version already include <a href="https://pip.pypa.io/en/latest/index.html#pip" target="_blank">PIP</a>.</b></span></div>
<div>
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: 20px;"><b>Follow the below pics to install Python</b></span><br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEjVc79KEuxRwSVZmuHyJWD6M1YUxtHVdA4C9EzqkfDysRZYUz7h3Xt9-1Ur7A02mf7fS-GszSSbjM5E_Gv5bMPv2VzjHvY0Et2ftI8w3UJsLN5H4TnAlnHJoRXICnEa5ZdPEgV4FbBLqq/s1600/000003.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEjVc79KEuxRwSVZmuHyJWD6M1YUxtHVdA4C9EzqkfDysRZYUz7h3Xt9-1Ur7A02mf7fS-GszSSbjM5E_Gv5bMPv2VzjHvY0Et2ftI8w3UJsLN5H4TnAlnHJoRXICnEa5ZdPEgV4FbBLqq/s1600/000003.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3qZHOnOLmX7nXMhsLYpTJ8aiTc0O9ktOpwL7nhNl3DHzHD7PLfXAsiUcNVvnUlUEmXSImI8agMa94-T78_4An9ArWUAuWKg4YBLMfYHUybQ_adlsdRStvbQD-mspJouJF5Q8wvQ6z6n3m/s1600/000004.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3qZHOnOLmX7nXMhsLYpTJ8aiTc0O9ktOpwL7nhNl3DHzHD7PLfXAsiUcNVvnUlUEmXSImI8agMa94-T78_4An9ArWUAuWKg4YBLMfYHUybQ_adlsdRStvbQD-mspJouJF5Q8wvQ6z6n3m/s1600/000004.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH8biGRte5JH_WSvDgg3-NlJM7vfwyaAvSZZgf0UgnASJLwBRq5Yjgikus1DDHaWXAAorYJz5mGsGEVn0vAxtwGDyo5BivXxwa3qBHvPuDJhjHjfzm1JD90Mdfc3yC6Xdj0BRnPfgv2D8_/s1600/000005.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjH8biGRte5JH_WSvDgg3-NlJM7vfwyaAvSZZgf0UgnASJLwBRq5Yjgikus1DDHaWXAAorYJz5mGsGEVn0vAxtwGDyo5BivXxwa3qBHvPuDJhjHjfzm1JD90Mdfc3yC6Xdj0BRnPfgv2D8_/s1600/000005.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1WCyBJqzxB9HNpDfPDhSuSW8DsraW_0MxKjlGxxSXokjAsG3RswiOf8GNXBwWXb9rRyqTmd0V3sBcZ7VttP60S8v8WVC28Fd5XCuAkLg-T4qRrioSSi4ijLvXf2uFBlGPizFpTIs8ws_/s1600/000006.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjr1WCyBJqzxB9HNpDfPDhSuSW8DsraW_0MxKjlGxxSXokjAsG3RswiOf8GNXBwWXb9rRyqTmd0V3sBcZ7VttP60S8v8WVC28Fd5XCuAkLg-T4qRrioSSi4ijLvXf2uFBlGPizFpTIs8ws_/s1600/000006.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLZOB9gFa-c-ZpVvtNfw_1fcetbZ4TWiPud_wvzXeP6Cqn9uRD8r7MD_y1Ij1aOQQjgzOtVLLGzP40VYVGs4CkC5sb_P0-R9o_9sASp9wWLl0zgFMwb1FJsILSEZesgK4cMVyIRJh8j4Zx/s1600/000009.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLZOB9gFa-c-ZpVvtNfw_1fcetbZ4TWiPud_wvzXeP6Cqn9uRD8r7MD_y1Ij1aOQQjgzOtVLLGzP40VYVGs4CkC5sb_P0-R9o_9sASp9wWLl0zgFMwb1FJsILSEZesgK4cMVyIRJh8j4Zx/s1600/000009.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbdl1nzKF0-fi2uukHmSo_Au9gq8ZeaCQmx4mdcOGYOQNo77XcOUQ8iw2-IRPRXDV2bgJJ9naSLZ324WiE-etxVNPquaKXKtUf4r-3Cswq2tnG5Xnl8WR-1T3S85k35_PlsQ3qwScfCkNA/s1600/000010.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbdl1nzKF0-fi2uukHmSo_Au9gq8ZeaCQmx4mdcOGYOQNo77XcOUQ8iw2-IRPRXDV2bgJJ9naSLZ324WiE-etxVNPquaKXKtUf4r-3Cswq2tnG5Xnl8WR-1T3S85k35_PlsQ3qwScfCkNA/s1600/000010.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvHs4GXxOf0fvZxuUIb0gbJ5DG93zQj7TXOvyysmy_Cp2-Zg9SgPMkALEalofgN8PTH4xkuoEKGrDUkts8DDaD02pkymvs5hk4eFaKBfoQ4Cu_0CtlBH6i_VSt81bMv4MGZUbpu7JtI2F7/s1600/000011.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvHs4GXxOf0fvZxuUIb0gbJ5DG93zQj7TXOvyysmy_Cp2-Zg9SgPMkALEalofgN8PTH4xkuoEKGrDUkts8DDaD02pkymvs5hk4eFaKBfoQ4Cu_0CtlBH6i_VSt81bMv4MGZUbpu7JtI2F7/s1600/000011.png" /></a></div>
</div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: 20px;"><b>3. If you have Python already installed in your system but do not have pip; <span style="color: red;"><a href="https://pip.pypa.io/en/latest/installing.html" target="_blank"><span style="color: red;">FOLLOW THIS QUICK AND EASY TUTORIAL</span></a> </span>and install pip.</b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: 20px;"><b><br /></b></span></div>
<div>
<span style="font-family: Courier New, Courier, monospace; font-size: 20px;"><b>4. To download pygame go to <span style="color: red;"><a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame" target="_blank"><span style="color: red;">PYGAME DOWNLOAD LINK</span></a> </span>and download the pygame according to the Python version and windows 32 bit or 64 bit.</b></span><br />
<b style="color: blue; font-family: 'Courier New', Courier, monospace; font-size: 20px;">Follow the below pics to install Pygame</b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRaKA-OiJvy7qcpOjKGXgEjI5DHyi79sD7M-wdPiHQhr6ASdUYVArWIzOTMInR0PUrFyonC-c4yfzgaffjvSO5mIEqym4VLH83S13_D8k-LWvzvIdzLoauQwsN4KVLJeoKCWARqpw5naX4/s1600/000012.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjRaKA-OiJvy7qcpOjKGXgEjI5DHyi79sD7M-wdPiHQhr6ASdUYVArWIzOTMInR0PUrFyonC-c4yfzgaffjvSO5mIEqym4VLH83S13_D8k-LWvzvIdzLoauQwsN4KVLJeoKCWARqpw5naX4/s1600/000012.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKLEvZVscaeKzYSyXR0UGJQCU-gUNEs4Za12P98tHMODng78Y4OmwrPX7yU6bzkXbCKjCp1ZhbSNzd1U-wj8JoI-_2098hcmV2-vmZkAUHiw04Fy0fb1h0SlSlDn33VLhIopPFpdS8Xddu/s1600/000013.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKLEvZVscaeKzYSyXR0UGJQCU-gUNEs4Za12P98tHMODng78Y4OmwrPX7yU6bzkXbCKjCp1ZhbSNzd1U-wj8JoI-_2098hcmV2-vmZkAUHiw04Fy0fb1h0SlSlDn33VLhIopPFpdS8Xddu/s1600/000013.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIbuewGy1l4r8QnNcWDtYDO76SL4XoQdNZDgDRa88KharpfNiHYcwW9rNdZKByRGAwM5q-KpDYOubXmpZPfMToTSbMba-3_VpRX8TSBaEKrkrmev9vCuqPaLIhVSf2YKQSSyH01xy_xtaC/s1600/000013-1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIbuewGy1l4r8QnNcWDtYDO76SL4XoQdNZDgDRa88KharpfNiHYcwW9rNdZKByRGAwM5q-KpDYOubXmpZPfMToTSbMba-3_VpRX8TSBaEKrkrmev9vCuqPaLIhVSf2YKQSSyH01xy_xtaC/s1600/000013-1.png" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj456FLmRqYeCV6rMCdu8CkRDGatJAzMDQF4GtdrM1Q_ApKX9rWDiomo7celfpqcWSUbjQFAzKe1B-7KN7ZH2EKIi6vKjE6wB-XJl2OkkY5jBRxjFhZ0e2EHLCVXOnhFRCbEZenmFoU4b4T/s1600/000013-2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj456FLmRqYeCV6rMCdu8CkRDGatJAzMDQF4GtdrM1Q_ApKX9rWDiomo7celfpqcWSUbjQFAzKe1B-7KN7ZH2EKIi6vKjE6wB-XJl2OkkY5jBRxjFhZ0e2EHLCVXOnhFRCbEZenmFoU4b4T/s1600/000013-2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNgu-mlSXywpiwDnvO59TdJkA4-mS_qU6og3PxuoEVJPcP7n-MkIQQbg2dV_XZoFQYZqmehAS_UhGaQa3hwKlZUuA8_ydJ-jCEyCIV85sQ1s5DdLcKxqedUJktIDT7Zv9qJq3BfMYFK8vc/s1600/000014.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNgu-mlSXywpiwDnvO59TdJkA4-mS_qU6og3PxuoEVJPcP7n-MkIQQbg2dV_XZoFQYZqmehAS_UhGaQa3hwKlZUuA8_ydJ-jCEyCIV85sQ1s5DdLcKxqedUJktIDT7Zv9qJq3BfMYFK8vc/s1600/000014.png" /></a></div>
<br />
<b style="font-family: 'Courier New', Courier, monospace; font-size: 20px;">Comments and suggestion are invited. :)</b><br />
<br />
<img alt="ahaaah" src="http://emoticoner.com/files/emoticons/onion-head/ahaaah-onion-head-emoticon.gif" /><img alt="cool" src="http://emoticoner.com/files/emoticons/onion-head/cool-onion-head-emoticon.gif" /></div>
</div>
Anonymoushttp://www.blogger.com/profile/05035455583114965257noreply@blogger.com11tag:blogger.com,1999:blog-953870660818525403.post-36199403725318216192012-12-11T04:33:00.000+05:302015-05-11T22:26:51.490+05:30chapter3 of head first programming (complete procedure and program to send message to twitter)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<ul>
<li><b style="font-family: 'Courier New', Courier, monospace; font-size: x-large;">First of all go to<span style="color: red;"> <a href="https://twitter.com/" target="_blank"><span style="color: red;">TWITTER</span></a> </span>and log in to your account.</b></li>
</ul>
<div>
<ul style="text-align: left;">
<li><b style="font-family: 'Courier New', Courier, monospace; font-size: x-large;">Follow the below pictures to create a new app. </b></li>
</ul>
<b style="font-family: 'Courier New', Courier, monospace; font-size: x-large;"><span style="color: #3d85c6;">Note: Instructions are written inside the pictures.</span></b><br />
<b style="font-family: 'Courier New', Courier, monospace; font-size: x-large;"><span style="color: #3d85c6;"><br /></span></b>
<br />
<ul>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUdtkYOtzY2gR0b_uudIZvTRKnSkOLhMpnFrA6fcIWPFpzDqTm0pTH3yJmb0b6C9eVZP6U2A37s1taMdH7geuZ0aDUT4Q7pnSPypQsuyUqCEJ19w3cG1CB0jiwIF7Yx-HvqFM2gWScYVkp/s1600/1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="315" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUdtkYOtzY2gR0b_uudIZvTRKnSkOLhMpnFrA6fcIWPFpzDqTm0pTH3yJmb0b6C9eVZP6U2A37s1taMdH7geuZ0aDUT4Q7pnSPypQsuyUqCEJ19w3cG1CB0jiwIF7Yx-HvqFM2gWScYVkp/s640/1.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFy9HCjf6sPw9ciVarTuGRpwU_VRIcfnTrML1VZKfQ_xv9o74ZitDb7zznie-PSWZ9bWx5uB-R-Llf59lFvgjGE9rCpBXSMUko0Vmj2B5PPc6wtSnR11StJiwhCGJPd34jqt5W-9NFbRQ/s1600/2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwFy9HCjf6sPw9ciVarTuGRpwU_VRIcfnTrML1VZKfQ_xv9o74ZitDb7zznie-PSWZ9bWx5uB-R-Llf59lFvgjGE9rCpBXSMUko0Vmj2B5PPc6wtSnR11StJiwhCGJPd34jqt5W-9NFbRQ/s1600/2.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgqBcLaVBT0OpqZbydrQrSt6iTdVfCMER_azrU2VnIrKN0R2jsFUb7fdU36rRy627ZNu8mLtYvYQcmQj0GaqmlUjloKbZb5G9JhZdksL2BNBUv7Cq1GnvqX35vdXCCmKNtl-Vgp9Y8ZnVS/s1600/3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgqBcLaVBT0OpqZbydrQrSt6iTdVfCMER_azrU2VnIrKN0R2jsFUb7fdU36rRy627ZNu8mLtYvYQcmQj0GaqmlUjloKbZb5G9JhZdksL2BNBUv7Cq1GnvqX35vdXCCmKNtl-Vgp9Y8ZnVS/s1600/3.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8SqtmezbAuFRO953F8cLoyyDiJCQQEpx8ZOF-KDiDAHVqmJoMZOd2L6pfY2nboJqcYrDCOvjc3Ik1Ide3xSWC7riP9iiAAsUj6zhdRuBjgwP-RAMc9p7WCNBdJwjU7BZP4T2yjUuvCOnu/s1600/4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8SqtmezbAuFRO953F8cLoyyDiJCQQEpx8ZOF-KDiDAHVqmJoMZOd2L6pfY2nboJqcYrDCOvjc3Ik1Ide3xSWC7riP9iiAAsUj6zhdRuBjgwP-RAMc9p7WCNBdJwjU7BZP4T2yjUuvCOnu/s1600/4.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdBruVsySyA4_N265UFi9zTP9nXDsgBPibyLUW2O5XSfVHkVTSuhIbfOYfXsF3qOqoXkEZxQL1IYEe65DqhNyNSIyeXiO1WRfaBoBgSXejUzxrq1z3c8NO8IgwAYFM-QIQ53UxTFhPOcUD/s1600/5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdBruVsySyA4_N265UFi9zTP9nXDsgBPibyLUW2O5XSfVHkVTSuhIbfOYfXsF3qOqoXkEZxQL1IYEe65DqhNyNSIyeXiO1WRfaBoBgSXejUzxrq1z3c8NO8IgwAYFM-QIQ53UxTFhPOcUD/s1600/5.png" width="640" /></a></div>
<ul>
<li><b style="font-family: 'Courier New', Courier, monospace; font-size: x-large;">Now you need to go to <a href="https://dev.twitter.com/" target="_blank"><span style="color: red;">TWITTER DEVELOPER'S PAGE</span></a> and follow the instructions below.</b></li>
</ul>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuH8Ecm1hdNmJaOB8LozW9OrWSmxtEj1O4H7im56AUtc-2Bjj30_vnEUeT28yK3mRZHSsoojIWaiWwYMY_rf_n-p5dIcMGCYblUP06JSKEiuNcWMShX6SUVjY6gQcLMqkFb0ANHW6aLM6J/s1600/6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuH8Ecm1hdNmJaOB8LozW9OrWSmxtEj1O4H7im56AUtc-2Bjj30_vnEUeT28yK3mRZHSsoojIWaiWwYMY_rf_n-p5dIcMGCYblUP06JSKEiuNcWMShX6SUVjY6gQcLMqkFb0ANHW6aLM6J/s1600/6.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4RapFyTwypHIEWOJ4ReszzwsJ6NDVzSjPTe8DW6jpd3q5IIUlApJrpNefPmkz_mA1pRiJEgZV7VjP8YM1zE7WWFWjX8j5IZN4ZI_FBou2p0qguVEyl-WqQxRzYxgXVTfPJw8VVAJgaEoT/s1600/7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4RapFyTwypHIEWOJ4ReszzwsJ6NDVzSjPTe8DW6jpd3q5IIUlApJrpNefPmkz_mA1pRiJEgZV7VjP8YM1zE7WWFWjX8j5IZN4ZI_FBou2p0qguVEyl-WqQxRzYxgXVTfPJw8VVAJgaEoT/s1600/7.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb-YOOFL6lsdaIpQ91YfgI1ehP2zqIzY_evZ8l2T2umtQIBu0Z8eXnyMaiFV0AgK6jd0cg043RcZu2zwYN8SiI9XFynMxEXse9NYs8kGh7j1sfBGe1PvtiskIhl3JwqmpXRn8HKnKguz_r/s1600/8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhb-YOOFL6lsdaIpQ91YfgI1ehP2zqIzY_evZ8l2T2umtQIBu0Z8eXnyMaiFV0AgK6jd0cg043RcZu2zwYN8SiI9XFynMxEXse9NYs8kGh7j1sfBGe1PvtiskIhl3JwqmpXRn8HKnKguz_r/s1600/8.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqkVwYe_pvK5SjodPvjoMwOIbZ7R9mNfxo0ix8Sz70NZwKDbb4wfncwA8hdO2nFXznkUKzx52Chn2FJWfDbczhlGOBqXji3yyeH1jwpHFzhJ_gHOi1stekZ2-jSTkTdixQPI_CXAze5HmF/s1600/9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqkVwYe_pvK5SjodPvjoMwOIbZ7R9mNfxo0ix8Sz70NZwKDbb4wfncwA8hdO2nFXznkUKzx52Chn2FJWfDbczhlGOBqXji3yyeH1jwpHFzhJ_gHOi1stekZ2-jSTkTdixQPI_CXAze5HmF/s1600/9.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifVkpyy2bUKZm7H_a_2KIEyeBGO4oUpdyflVYzNef12HyROKNOLN8ZWJaa7rzcljopCsCtmSn_twS9WBya-gkH5WDHSjjmGOMcuAfBhZHW1BZ_lEMqZZx9dcvYbwFsmgQzEygKFQlJQTUb/s1600/10.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifVkpyy2bUKZm7H_a_2KIEyeBGO4oUpdyflVYzNef12HyROKNOLN8ZWJaa7rzcljopCsCtmSn_twS9WBya-gkH5WDHSjjmGOMcuAfBhZHW1BZ_lEMqZZx9dcvYbwFsmgQzEygKFQlJQTUb/s1600/10.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguZ_RVxTS_4SqU7lwwILYUy30MCfh7QMzjykwCzWqmuVlrDuP9qB2XCARUDMUYJA34DITrGMDulZqx0nnyHVc2r81GcBbpopj_jjAEhM1cju98uEXN1WW3yeCpHhVvi5dOvKVI_A8rXVH9/s1600/11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="294" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguZ_RVxTS_4SqU7lwwILYUy30MCfh7QMzjykwCzWqmuVlrDuP9qB2XCARUDMUYJA34DITrGMDulZqx0nnyHVc2r81GcBbpopj_jjAEhM1cju98uEXN1WW3yeCpHhVvi5dOvKVI_A8rXVH9/s1600/11.png" width="640" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwjPtEvkEDT3nmH-s17N0D-YkYH0FYaGKOweEUgWD6vgCNbLKB3LRDfp23ud9Cwn4HbCsVglVplyF9KwfPAotgx20xyFe6bHS7UixxZRQRi5Yv1PkL5ViFaPcvMHW5keADvUIJ48R0HI86/s1600/12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwjPtEvkEDT3nmH-s17N0D-YkYH0FYaGKOweEUgWD6vgCNbLKB3LRDfp23ud9Cwn4HbCsVglVplyF9KwfPAotgx20xyFe6bHS7UixxZRQRi5Yv1PkL5ViFaPcvMHW5keADvUIJ48R0HI86/s1600/12.png" width="640" /></a></div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1bCjPgEtG9WR6RE2CVNmIDYwsMnBiGm56DJsaiD2IwsxcZ-ioUzfVxIjGpfifhuoLY6MohAFwPzYl8Dm7CVdWFQaqTzHHzu1nRq5PhNC1JzbTDlNgaL3wGglZ9D4XysnIv2lm7RrxCmig/s1600/13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="284" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1bCjPgEtG9WR6RE2CVNmIDYwsMnBiGm56DJsaiD2IwsxcZ-ioUzfVxIjGpfifhuoLY6MohAFwPzYl8Dm7CVdWFQaqTzHHzu1nRq5PhNC1JzbTDlNgaL3wGglZ9D4XysnIv2lm7RrxCmig/s1600/13.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOhHIWSRo9ciYISckZ8WU49aFCbt6QC7nPWWrDg8AARk-WCy1wDQ0VQYv5DN9-CDe7ZKzwR1frhEzL0IqAtRRWHVdnqkPBOsxdwmSB2CLhooIVZVSUGLoGaovXsXpZcX7qpMT7oQsGRHqy/s1600/14.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOhHIWSRo9ciYISckZ8WU49aFCbt6QC7nPWWrDg8AARk-WCy1wDQ0VQYv5DN9-CDe7ZKzwR1frhEzL0IqAtRRWHVdnqkPBOsxdwmSB2CLhooIVZVSUGLoGaovXsXpZcX7qpMT7oQsGRHqy/s1600/14.png" width="640" /></a></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><b>Now we are all done with Twitter application authentication process !!</b></span><br />
<span style="font-family: Courier New, Courier, monospace; font-size: large;"><b>So long. Take some tea or coffee break !!</b></span><br />
<img alt="sweat" src="http://emoticoner.com/files/emoticons/onion-head/sweating-onion-head-emoticon.gif" /><br />
<br />
<span style="color: red;"><i>################################################################################</i></span><br />
<span style="color: red;"><span style="font-size: large;"><i><b><b><span style="font-family: Arial, Helvetica, sans-serif; font-size: large;">INSTALLATION INSTRUCTIONS AND LINKS FOR</span></b> <span style="font-size: x-large;">pip</span> AND </b></i></span><i><b><span style="font-size: x-large;"><a href="https://pypi.python.org/pypi/twitter/" target="_blank">twitter version 1.16.0</a> </span><span style="font-size: large;">OR LOWER .</span></b></i></span><br />
<i style="color: red;">################################################################################</i><br />
<span style="color: #f1c232;"><i><b><span style="background-color: yellow;"><span style="color: purple;">NOTE: YOU NEED TO USE COMMAND PROMPT (ON WINDOWS) AND TERMINAL (ON LINUX AND MAC) WITH ADMIN PRIVILEGE FOR INSTALLING PIP AND TWITTER API.</span></span></b> </i></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: purple; font-size: large;"><b></b></span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: red; font-size: large;"><b>For Linux (yum and apt based):</b></span></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: purple; font-size: large;"><b><br /></b></span>
<span style="font-size: large;"><span style="color: purple;"><b>1. </b></span><b style="color: purple;">yum install python-pip python3-pip</b></span></span><br />
<span style="color: purple; font-family: Arial, Helvetica, sans-serif; font-size: large;"><b> or </b></span><br />
<span style="color: purple; font-family: Arial, Helvetica, sans-serif; font-size: large;"><b> sudo apt-get install python-pip python3-pip</b></span><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: purple; font-size: large;"><b><br /></b></span>
<span style="color: blue;"><b><span style="font-size: x-large;"><a href="http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows" target="_blank">For Windows click me</a></span></b></span></span><br />
<span style="color: blue;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: large;"><br /></span>
<b><a href="http://stackoverflow.com/questions/17271319/installing-pip-on-mac-os-x" target="_blank"><span style="font-size: x-large;">For Mac OS click me</span></a><span style="font-size: x-large;"> </span></b></span></span><br />
<b style="font-size: x-large;"></b><br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: large;"><b style="color: purple;"> OR</b></span></span><br />
<br />
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="font-size: large;"><b style="color: purple;">FOLLOW <span style="color: red;"><a href="https://pip.pypa.io/en/latest/installing.html">THIS PIP INSTALLATION GUIDE (CLICK ME)</a></span></b></span></span><br />
<br />
<span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: purple; font-size: large;"><b>2.</b></span></span></span><span style="color: red;"><span style="font-family: Arial, Helvetica, sans-serif;"><span style="color: purple; font-size: large;"><b> pip install twitter</b></span></span></span><br />
<span style="color: purple; font-family: Arial, Helvetica, sans-serif; font-size: large;"><b>3. pip3 install twitter</b></span><br />
<br />
<i style="color: red;">################################################################################</i><br />
<b><span style="color: red; font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Script for python-2.7.x (tested using python-2.7.8) :</span></b><br />
<!-- HTML generated using hilite.me --><i style="color: red;">################################################################################</i><br />
<div style="background: #f8f8f8; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">twitter</span> <span style="color: #204a87; font-weight: bold;">as</span> <span style="color: black;">t</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">urllib2</span> <span style="color: #204a87; font-weight: bold;">as</span> <span style="color: black;">ur</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">time</span>
<span style="color: black;">CONSUMER_KEY</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' </span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API key</span>
<span style="color: black;">CONSUMER_SECRET</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' </span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API secret</span>
<span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This function updates the status of my twitter account</span>
<span style="color: #8f5902; font-style: italic;">requires twitter python module</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: #204a87;">len</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">140</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">raise</span> <span style="color: #cc0000; font-weight: bold;">Exception</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'Status message too long !!!'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">authkey</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">t</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">Twitter</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">auth</span><span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: black;">t</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">OAuth</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">CONSUMER_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">CONSUMER_SECRET</span><span style="color: black; font-weight: bold;">))</span>
<span style="color: black;">result</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">authkey</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">statuses</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">update</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status</span><span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: black;">result</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This function get the coffee price (both below a desired price and in emergency; the current price)</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: black;">text</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">page</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">read</span><span style="color: black; font-weight: bold;">()</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">decode</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"utf8"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">text</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">find</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'>$'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">2</span>
<span style="color: black;">eoss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">4</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: #204a87;">float</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">text</span><span style="color: black; font-weight: bold;">[</span><span style="color: black;">soss</span><span style="color: black; font-weight: bold;">:</span><span style="color: black;">eoss</span><span style="color: black; font-weight: bold;">])</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">main program</span>
<span style="color: #8f5902; font-style: italic;">requires urllib.request</span>
<span style="color: #8f5902; font-style: italic;">requires time library also.</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Welcome to Starbuzz Coffee price checking program"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #204a87;">raw_input</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Do You want to know the coffee price immediately ?? (y/n) : "</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">==</span> <span style="color: #4e9a06;">"y"</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">page</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ur</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">status_msg</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee = $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: #0000cf; font-weight: bold;">99.99</span>
<span style="color: #204a87; font-weight: bold;">while</span> <span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">4.74</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">time</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">sleep</span><span style="color: black; font-weight: bold;">(</span><span style="color: #0000cf; font-weight: bold;">10</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">page</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ur</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices-loyalty.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">status_msg</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee is $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #4e9a06;">"; BUY !!!"</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">!=</span> <span style="color: #3465a4;">None</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"tweeted coffee price successfully to Starbuzz CEO"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"problem !!"</span><span style="color: black; font-weight: bold;">)</span>
</pre>
</td></tr>
</tbody></table>
</div>
<br />
<i style="color: red;">################################################################################</i><b><span style="color: red; font-family: Arial, Helvetica, sans-serif; font-size: x-large;"> </span></b><br />
<b><span style="color: red; font-family: Arial, Helvetica, sans-serif; font-size: x-large;">Script for python-3.x (tested using python-3.4.1) :</span></b><br />
<i style="color: red;">################################################################################</i>
<!-- HTML generated using hilite.me --><br />
<div style="background: #f8f8f8; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">twitter</span> <span style="color: #204a87; font-weight: bold;">as</span> <span style="color: black;">t</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">urllib.request</span> <span style="color: #204a87; font-weight: bold;">as</span> <span style="color: black;">ur</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">time</span>
<span style="color: black;">CONSUMER_KEY</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' </span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API key</span>
<span style="color: black;">CONSUMER_SECRET</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' </span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API secret</span>
<span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This function updates the status of my twitter account</span>
<span style="color: #8f5902; font-style: italic;">requires twitter python module</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: #204a87;">len</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">140</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">raise</span> <span style="color: #cc0000; font-weight: bold;">Exception</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'Status message too long !!!'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">authkey</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">t</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">Twitter</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">auth</span><span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: black;">t</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">OAuth</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">CONSUMER_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">CONSUMER_SECRET</span><span style="color: black; font-weight: bold;">))</span>
<span style="color: black;">result</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">authkey</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">statuses</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">update</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status</span><span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: black;">result</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This function get the coffee price (both below a desired price and in emergency; the current price)</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: black;">text</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">page</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">read</span><span style="color: black; font-weight: bold;">()</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">decode</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"utf8"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">text</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">find</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'>$'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">2</span>
<span style="color: black;">eoss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">4</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: #204a87;">float</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">text</span><span style="color: black; font-weight: bold;">[</span><span style="color: black;">soss</span><span style="color: black; font-weight: bold;">:</span><span style="color: black;">eoss</span><span style="color: black; font-weight: bold;">])</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">main program</span>
<span style="color: #8f5902; font-style: italic;">requires urllib.request</span>
<span style="color: #8f5902; font-style: italic;">requires time library also.</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Welcome to Starbuzz Coffee price checking program"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #204a87;">input</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Do You want to know the coffee price immediately ?? (y/n) : "</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">==</span> <span style="color: #4e9a06;">"y"</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">page</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ur</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">status_msg</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee = $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: #0000cf; font-weight: bold;">99.99</span>
<span style="color: #204a87; font-weight: bold;">while</span> <span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">4.74</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">time</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">sleep</span><span style="color: black; font-weight: bold;">(</span><span style="color: #0000cf; font-weight: bold;">10</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">page</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ur</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices-loyalty.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">status_msg</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee is $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #4e9a06;">"; BUY !!!"</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status_msg</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">!=</span> <span style="color: #3465a4;">None</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"tweeted coffee price successfully to Starbuzz CEO"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"problem !!"</span><span style="color: black; font-weight: bold;">)</span>
</pre>
</td></tr>
</tbody></table>
</div>
<br />
<i style="color: red;">################################################################################</i><span style="color: red;"><i><br /></i></span>
<span style="color: red; font-size: large;"><i><b>SCRIPTS FOR PYTHON 2.7.X USING <a href="https://pypi.python.org/pypi/tweepy/" target="_blank">tweepy</a></b></i></span><br />
<i style="color: red;">################################################################################</i><br />
<i><b>Try it yourself for Python 3.X.</b></i><br />
<!-- HTML generated using hilite.me --><br />
<div style="background: #f8f8f8; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;">
<table><tbody>
<tr><td><pre style="line-height: 125%; margin: 0;"> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58</pre>
</td><td><pre style="line-height: 125%; margin: 0;"><span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">tweepy</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">urllib2</span>
<span style="color: #204a87; font-weight: bold;">import</span> <span style="color: black;">time</span>
<span style="color: black;">CONSUMER_KEY</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API key</span>
<span style="color: black;">CONSUMER_SECRET</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span><span style="color: #8f5902; font-style: italic; line-height: 125%;"># Same as API secret</span>
<span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #4e9a06;">'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This below function updates the status of my twitter account</span>
<span style="color: #8f5902; font-style: italic;">requires tweepy</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: #204a87;">len</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">140</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">raise</span> <span style="color: #cc0000; font-weight: bold;">Exception</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'Status message too long !!!'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">auth</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweepy</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">OAuthHandler</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">CONSUMER_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">CONSUMER_SECRET</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">auth</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">set_access_token</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">ACCESS_TOKEN_KEY</span><span style="color: black; font-weight: bold;">,</span> <span style="color: black;">ACCESS_TOKEN_SECRET</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">api</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweepy</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">API</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">auth</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">result</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">api</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">update_status</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">status</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: black;">result</span>
<span style="color: #8f5902; font-style: italic;"># I do not feel any need of this though.</span>
<span style="color: #8f5902; font-style: italic;">#it is always good to make a function return something</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">This below function get the coffee price (both below a desired price and in emergency; the current price)</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">def</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page</span><span style="color: black; font-weight: bold;">):</span>
<span style="color: black;">text</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">page</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">read</span><span style="color: black; font-weight: bold;">()</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">decode</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"utf8"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">text</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">find</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">'>$'</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">ss_pos</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">2</span>
<span style="color: black;">eoss</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">soss</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #0000cf; font-weight: bold;">4</span>
<span style="color: #204a87; font-weight: bold;">return</span> <span style="color: #204a87;">float</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">text</span><span style="color: black; font-weight: bold;">[</span><span style="color: black;">soss</span><span style="color: black; font-weight: bold;">:</span><span style="color: black;">eoss</span><span style="color: black; font-weight: bold;">])</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #8f5902; font-style: italic;">main program</span>
<span style="color: #8f5902; font-style: italic;">requires urllib2 (incase of python 2.7.x series)</span>
<span style="color: #8f5902; font-style: italic;">requires time library also.</span>
<span style="color: #8f5902; font-style: italic;">'''</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Welcome to Starbuzz Coffee price checking program"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: #204a87;">raw_input</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"Do You want to know the coffee price immediately ?? (y/n) : "</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">choice</span> <span style="color: #ce5c00; font-weight: bold;">==</span> <span style="color: #4e9a06;">"y"</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">page_emergency</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">urllib2</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page_emergency</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee = $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">))</span>
<span style="color: #204a87; font-weight: bold;">else</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span><span style="color: #0000cf; font-weight: bold;">99.99</span>
<span style="color: #204a87; font-weight: bold;">while</span> <span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">></span> <span style="color: #0000cf; font-weight: bold;">4.74</span> <span style="color: black; font-weight: bold;">:</span>
<span style="color: black;">time</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">sleep</span><span style="color: black; font-weight: bold;">(1</span><span style="color: #0000cf; font-weight: bold;">0</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">page_optimal</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">urllib2</span><span style="color: #ce5c00; font-weight: bold;">.</span><span style="color: black;">urlopen</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"http://beans.itcarlow.ie/prices-loyalty.html"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">price</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">get_price</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">page_optimal</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">=</span> <span style="color: black;">tweet</span><span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"@starbuzzceo\nCurrent price of coffee is $"</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #204a87;">str</span><span style="color: black; font-weight: bold;">(</span><span style="color: black;">price</span><span style="color: black; font-weight: bold;">)</span> <span style="color: #ce5c00; font-weight: bold;">+</span> <span style="color: #4e9a06;">"; BUY !!!"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">if</span> <span style="color: black;">res</span> <span style="color: #ce5c00; font-weight: bold;">!=</span> <span style="color: #3465a4;">None</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"tweeted coffee price successfully to starbuzz ceo"</span><span style="color: black; font-weight: bold;">)</span>
<span style="color: #204a87; font-weight: bold;">else</span><span style="color: black; font-weight: bold;">:</span>
<span style="color: #204a87; font-weight: bold;">print</span> <span style="color: black; font-weight: bold;">(</span><span style="color: #4e9a06;">"problem !!"</span><span style="color: black; font-weight: bold;">)</span>
</pre>
</td></tr>
</tbody></table>
</div>
<span style="font-family: Arial, Helvetica, sans-serif;">suggestions and comments are invited.</span><br />
<br />
<br />
<img alt="ahaaah" src="http://emoticoner.com/files/emoticons/onion-head/ahaaah-onion-head-emoticon.gif" /> <img alt="cool" src="http://emoticoner.com/files/emoticons/onion-head/cool-onion-head-emoticon.gif" /> </div>
Anonymoushttp://www.blogger.com/profile/05035455583114965257noreply@blogger.com22