Skip to content

Instantly share code, notes, and snippets.

View kadnan's full-sized avatar
📢
Working from home

Adnan Siddiqi kadnan

📢
Working from home
View GitHub Profile
@kadnan
kadnan / listing_seq.py
Created December 11, 2016 08:21
Scraping OLX Listing
import requests
from bs4 import BeautifulSoup
from time import sleep
def get_listing(url):
headers = {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'}
html = None
links = None
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kadnan
kadnan / consumer-notification.py
Created June 10, 2018 18:54
Consumer that notifies if calories count cross the threshold
import json
from time import sleep
from kafka import KafkaConsumer
if __name__ == '__main__':
parsed_topic_name = 'parsed_recipes'
# Notify if a recipe has more than 200 calories
calories_threshold = 200
import json
from time import sleep
from bs4 import BeautifulSoup
from kafka import KafkaConsumer, KafkaProducer
def publish_message(producer_instance, topic_name, key, value):
try:
key_bytes = bytes(key, encoding='utf-8')
@kadnan
kadnan / fabfile
Created May 15, 2017 10:22
Gist for Automating remote and local git commands
from fabric.api import *
from fabric.colors import red, green
from time import sleep
from pprint import pprint
from fabric.contrib.files import exists
def local_git():
is_done = True
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kadnan
kadnan / docker-compose.yaml
Last active May 15, 2019 09:01
Docker compose file for running Cassandra Cluster
version: '2'
services:
cas1:
container_name: cas1
image: cassandra:latest
volumes:
- /Development/PetProjects/CassandraTut/data/node1:/var/lib/cassandra/data
ports:
- 9042:9042

Keybase proof

I hereby claim:

  • I am kadnan on github.
  • I am kadnan (https://keybase.io/kadnan) on keybase.
  • I have a public key ASAHNs8LV2Ck6XIFQPi-XKiD1amTKsrvPY8RTrvsBr13lwo

To claim this, I am signing this object:

@kadnan
kadnan / cl2.py
Created October 13, 2018 10:01
Anti Captcha test
import requests
from bs4 import BeautifulSoup
from python_anticaptcha import NoCaptchaTaskProxylessTask, AnticaptchaClient
def get_token(s_key):
client = AnticaptchaClient(api_key)
task = NoCaptchaTaskProxylessTask(website_url=url,
website_key=s_key.strip())
job = client.createTask(task)
@kadnan
kadnan / producer-raw-recipies.py
Created June 10, 2018 11:38
methods to access recipes listing and extract markup
def fetch_raw(recipe_url):
html = None
print('Processing..{}'.format(recipe_url))
try:
r = requests.get(recipe_url, headers=headers)
if r.status_code == 200:
html = r.text
except Exception as ex:
print('Exception while accessing raw html')
print(str(ex))