Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12323

sh: 1: Syntax error: "(" unexpected Getting this error when tries to run a python script on ubuntu 16.04

$
0
0

Here is my script I don't even know what caused the error so I am posting the whole script.

from bs4 import BeautifulSoupimport requestsimport pandas as pdimport timeimport osdef main():    url = "https://desiremovies.cyou"    html = requests.get(url)    soup = BeautifulSoup(html.content, 'html.parser')    moviesList = soup.find_all('article')    linksToGoWith ={}    postLinks=[]    linksFromCsv=[]    dfcsv = pd.read_csv('movies_posted.csv',header=None)    listInList=dfcsv.values.tolist()    for l in listInList:        linksFromCsv.append(l[0])    for heading in moviesList:        title = heading.find('h3').text.strip()        link = heading.find('h3').find('a')['href']        if (title.find('480p') != -1):             linksToGoWith[title]=link        if (title.find('Watch iPL') != -1 or title.find('Live') != -1 ):            postLinks.append(link)    for i in linksToGoWith:        if i not in linksFromCsv:            postLinks.append(linksToGoWith[i])    df = pd.concat([dfcsv, (pd.DataFrame(postLinks))], ignore_index=True)    df.to_csv('movies_posted.csv')    def post(link):        html = requests.get(link)        soup = BeautifulSoup(html.content, 'html.parser')        tmb = soup.find('figure',class_="entry-thumbnail")        tmblink = tmb.find('img')['src']        image=requests.get(tmblink).content        filename = "thumb"        with open(filename, "wb") as f:            f.write(image)        title ="**"+ soup.find('h1').text+"**"        message=""        message = message +"**-: LINKS :-** " +link  #this message is 400 charecter long                   os.system('telegram-send '+title)        time.sleep(2)        os.system('telegram-send --image '+filename)        time.sleep(2)        os.system('telegram-send '+message)        time.sleep(2)        os.remove(filename)     for plink in postLinks:        post(plink)if __name__ == "__main__":    main()

The script sends messages to the Telegram channel using Telegram API. Even after the error, it sends the image but it's not sending the text messages.

Please help me to fix it

Here is the error sequence

hidarshan0001@instance-1:~/telegram_autopost_bot$ python3 dm.pysh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 2: -:: not foundsh: 3: Title:: not foundsh: 4: Year:: not foundsh: 5: Size:: not foundsh: 6: Quality:: not foundsh: 7: IMDb:: not foundsh: 8: Language:: not foundsh: 9: Thriller: not foundsh: 9: All: not foundsh: 10: Plot:Two: not foundsh: 11: **-:: not foundsh: 12: https://desiremovies.cyou/world-trade-center-2006-720p-480p-bluray-dual-audio-hindi-eng-x264-1-4gb-450mb/: not foundsh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 1: Syntax error: "(" unexpectedsh: 2: -:: not foundsh: 3: Title:: not foundsh: 4: Year:: not foundsh: 6: Quality:: not foundsh: 7: IMDb:: not foundsh: 8: Language:: not foundsh: 9: Adventure: not foundsh: 9: All: not foundsh: 10: Plot:A: not foundsh: 11: -: ScreenShot:-: not foundsh: 12: **-:: not foundsh: 13: https://desiremovies.cyou/moontrap-target-earth-2017-720p-480p-bluray-dual-audio-hindi-eng-x264-750mb-300mb/: not foundsh: 1: Syntax error: "(" unexpected^Xsh: 1: Syntax error: "(" unexpectedpd.DataFrame(postLinks)^CTraceback (most recent call last):  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 377, in _make_request    httplib_response = conn.getresponse(buffering=True)TypeError: getresponse() got an unexpected keyword argument 'buffering'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "dm.py", line 73, in <module>    main()  File "dm.py", line 70, in main    post(plink)  File "dm.py", line 39, in post    html = requests.get(link)  File "/usr/lib/python3/dist-packages/requests/api.py", line 67, in get    return request('get', url, params=params, **kwargs)  File "/usr/lib/python3/dist-packages/requests/api.py", line 53, in request    return session.request(method=method, url=url, **kwargs)  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 480, in request    resp = self.send(prep, **send_kwargs)  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 588, in send    r = adapter.send(request, **kwargs)  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 376, in send  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 560, in urlopen    body=body, headers=headers)  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 379, in _make_request    httplib_response = conn.getresponse()  File "/usr/lib/python3.6/http/client.py", line 1379, in getresponse    response.begin()  File "/usr/lib/python3.6/http/client.py", line 311, in begin    version, status, reason = self._read_status()  File "/usr/lib/python3.6/http/client.py", line 272, in _read_status    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")  File "/usr/lib/python3.6/socket.py", line 586, in readinto    return self._sock.recv_into(b)  File "/usr/lib/python3.6/ssl.py", line 1012, in recv_into    return self.read(nbytes, buffer)  File "/usr/lib/python3.6/ssl.py", line 874, in read    return self._sslobj.read(len, buffer)  File "/usr/lib/python3.6/ssl.py", line 631, in read    v = self._sslobj.read(len, buffer)KeyboardInterrupt

Please check added the error log..


Viewing all articles
Browse latest Browse all 12323

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>