0
나는 나의 지역에서 무료 음식을 식별하는 방법으로 BeautifulSoup와 Twilio API를 실행하기 위해 Python을 사용하고 있습니다.Twilio와 Beautiful Soup이 구문 오류를 다시 보냄
나는 메모장에 ++로 쓴 다음 코드를 사용하여 다운로드 폴더에 experiment.py로 저장합니다.
from bs4 import BeautifulSoup
import requests
from twilio.rest import TwilioRestClient
import re
url = 'https://postmates.com/new-york-city'
account_sid = 'XXX'
auth_token = 'XXX'
twilio_phone_number = '+15551254565'
my_phone_number = '+15551234567'
webpage = requests.get(url)
soup = BeautifulSoup(webpage.text, 'html.parser')
free_regex = re.compile('free')
all_strings = list(soup.stripped_strings)
free_food = [s for s in all_strings if free_regex.match(s.lower())]
if free_food:
body = 'Free Postmates!\n\n' + '\n'.join(free_food)
client = TwilioRestClient(account_sid, auth_token)
client.messages.create(
body=body,
to=my_phone_number,
from=twilio_phone_number
)
cd downloads experiment.py를 입력하여 터미널에서 실행하려고하면 다음 메시지가 표시됩니다. =에서
파일 "experiment.py", 라인 25 twilio_phone_number ^ 구문 에러 : 유효하지 않은 구문
이 발생하는 원인이 될 수 무엇. 여기에 구문 오류가 표시되지 않습니다.