As the title suggest, this script is used to open top 10 Google search results in different tabs for provided keyword.

Code:

Python

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

"""

Author: Anurag Rana

Usage: python google.py <keyword>

Description: Script googles the keyword and opens top 10(max) search results in separate tabs in the browser

Usage: python filename.py keyword

Tested with Python3

"""

importwebbrowser

importsys

importpyperclip

importrequests

importbs4

defstart():

iflen(sys.argv)>1:

keyword=' '.join(sys.argv[1:])

else:

# if no keyword is entered, the script would

# search for the keyword copied in the clipboard

keyword=pyperclip.paste()

res=requests.get('https://google.com/search?q='+keyword)

soup=bs4.BeautifulSoup(res.text,'lxml')

links=soup.select('.r a')

tab_counts=min(10,len(links))

foriinrange(tab_counts):

webbrowser.open('https://google.com'+links[i].get('href'))

start()

I am using this same concept at my work. Every day I have to open 8 applications (slack, JIRA, gitlab, Facebook :p, stackoverflow, Jenkins UI, Outlook and Personal Email) in my browser. So instead of opening each application one by one, I just run the script and all these applications are opened in different tabs saving few seconds :D.

In this article we will see how to create a completely automated telegram channel. To demonstrate the process we will take through the example of a telegram channel News India (https://t.me/newsindiachannel) created by me which post news every hour.

The automated process of generating content and posting on the channel is divided into three parts. Creating telegram channel and bot, generating/fetching content using python script and posting the content to telegram channel.

Creating telegram channel and Bot:

-Install telegram app from Google Play.
-After you are done with initial setup. Click on menu and create a new channel.

While working on some django project you might feel that the default user model is not fulfilling all the requirements. For example you may want to authenticate users by email Id and not by username. You may want to store some more extra information in the user model. In short you might want to define your own custom user model.

In particular we may encounter one out of below four scenarios:

You are happy with the way default authentication but you need to store extra information in the model itself.

You want different authentication process, for example using email, but do not want to store extra information.