Skip to content

Instantly share code, notes, and snippets.

@niyumard
niyumard / divar.py
Created February 22, 2021 18:41
Gets a text file with urls and extracts info for renting houses from divar.ir
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import convert_numbers
from csv import writer
URL_List_as_txt = open('url.lst', 'r')
URLs = URL_List_as_txt.read().splitlines()
for URL in URLs:
@niyumard
niyumard / lingueeaudio.py
Created September 7, 2019 15:32
This script extracts audio for French words from Linguee dictionary
#!/usr/bin/python3
import requests, sys, os
from bs4 import BeautifulSoup
try:
r = requests.get("https://www.linguee.com/english-french/search", data={'query': sys.argv[1]})
#print(r.status_code, r.reason)
if r.status_code == 200 and r.reason == 'OK':
pass
else:
@niyumard
niyumard / lernulookup.py
Last active October 27, 2020 14:53
This script looks up esperanto words in Lernu.net website, this script is specially made for being used via GoldenDict. Usage: >python lernulookup.py %GDWORD%
#!/usr/bin/python
import requests,re, sys
from bs4 import BeautifulSoup
URL = 'https://lernu.net/en/vortaro'
client = requests.session()
# Retrieve the CSRF token first
z = client.get(URL) # sets cookie
if 'YII_CSRF_TOKEN' in client.cookies and 'PHPSESSID' in client.cookies:
@niyumard
niyumard / rolldice.py
Created February 10, 2019 16:59
Draw chart for rolling dice for k times
import random
import matplotlib.pyplot as plt
#How many times do you want the loop to run?
howmanytimes = 1000000
k = 4
def dice():
r = ''
for j in range(0,k):
r += str(random.randint(1,6))