想請問要怎麼把執行出來的\n去除,且要如何放進line bot程式裡?
試了很久都用不出來
import requests
from bs4 import BeautifulSoup
url1 = 'https://invoice.etax.nat.gov.tw/'
html1 = requests.get(url1)
moneys = [["期別","頭獎","特別獎","特獎","頭獎","增開六獎"]]
sp = BeautifulSoup(html1.text, 'lxml')
all1 = sp.find("div", class_="container-xl")
#print(all1)
date = sp.find("div", class_="carousel-item active").find('a')
tb = sp.find('span', class_='font-weight-bold etw-color-red')
t = sp.find_all('span', class_='font-weight-bold etw-color-red')[1]
head1 = sp.find("p", class_="etw-tbiggest mb-md-4")
head2 = sp.find_all("p", class_="etw-tbiggest mb-md-4")[1]
head3 = sp.find_all("p", class_="etw-tbiggest mb-md-4")[2]
add1 = sp.find_all("span", class_="font-weight-bold etw-color-red")
money=[date.text,
tb.text,
t.text,
head1.text,
head2.text,
head3.text,
add1[-1].text]
moneys.append(money)
for money in moneys:
print(money)
去除換行的部分參考:
https://www.w3schools.com/python/ref_string_replace.asp
放進去 linebot 程式內: