redis_set.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. import opengraph
  2. import redis
  3. from jinja2 import Environment, BaseLoader
  4. import traceback
  5. data="""
  6. {
  7. "type": "bubble",
  8. "header": {
  9. "type": "box",
  10. "layout": "vertical",
  11. "contents": [
  12. {
  13. "type": "text",
  14. "text": "集仕多 ChoozMo",
  15. "weight": "bold",
  16. "size": "xl",
  17. "color": "#ffffff"
  18. },
  19. {
  20. "type": "text",
  21. "text": "新聞 AI 主播媒體聯播網最佳方案",
  22. "size": "md",
  23. "color": "#ffffff"
  24. },
  25. {
  26. "type": "box",
  27. "layout": "baseline",
  28. "margin": "md",
  29. "contents": [
  30. {
  31. "type": "icon",
  32. "size": "xxl",
  33. "url": "https://ppt.cc/fLP10x@.png",
  34. "offsetTop": "xs"
  35. }
  36. ],
  37. "justifyContent": "flex-end",
  38. "offsetStart": "255px",
  39. "position": "absolute",
  40. "offsetBottom": "20px"
  41. }
  42. ],
  43. "backgroundColor": "#e1642b"
  44. },
  45. "hero": {
  46. "type": "image",
  47. "url": "https://ppt.cc/fDmzAx@.png",
  48. "size": "full",
  49. "aspectRatio": "20:13",
  50. "action": {
  51. "type": "uri",
  52. "uri": "http://linecorp.com/"
  53. },
  54. "offsetTop": "lg"
  55. },
  56. "body": {
  57. "type": "box",
  58. "layout": "vertical",
  59. "contents": [
  60. {
  61. "type": "text",
  62. "text": "圖文+影音+聯播",
  63. "color": "#aaaaaa",
  64. "size": "sm"
  65. },
  66. {
  67. "type": "text",
  68. "text": "全方位媒體曝光,一次到位!",
  69. "color": "#aaaaaa",
  70. "size": "sm"
  71. },
  72. {
  73. "type": "box",
  74. "layout": "baseline",
  75. "margin": "md",
  76. "contents": [
  77. {
  78. "type": "icon",
  79. "size": "md",
  80. "url": "https://ppt.cc/feXZPx@.png",
  81. "offsetTop": "xs"
  82. },
  83. {
  84. "type": "text",
  85. "text": "網路新聞圖文報導",
  86. "offsetStart": "md",
  87. "color": "#e47e4d",
  88. "weight": "bold"
  89. }
  90. ]
  91. },
  92. {
  93. "type": "box",
  94. "layout": "baseline",
  95. "margin": "md",
  96. "contents": [
  97. {
  98. "type": "icon",
  99. "size": "md",
  100. "url": "https://ppt.cc/feXZPx@.png",
  101. "offsetTop": "xs"
  102. },
  103. {
  104. "type": "text",
  105. "text": "十二家網路媒體聯播",
  106. "offsetStart": "md",
  107. "color": "#e47e4d",
  108. "weight": "bold"
  109. }
  110. ]
  111. },
  112. {
  113. "type": "box",
  114. "layout": "baseline",
  115. "margin": "md",
  116. "contents": [
  117. {
  118. "type": "icon",
  119. "size": "md",
  120. "url": "https://ppt.cc/feXZPx@.png",
  121. "offsetTop": "xs"
  122. },
  123. {
  124. "type": "text",
  125. "text": "AI 主播影音播報影片",
  126. "offsetStart": "md",
  127. "color": "#e47e4d",
  128. "weight": "bold"
  129. }
  130. ]
  131. },
  132. {
  133. "type": "box",
  134. "layout": "horizontal",
  135. "margin": "lg",
  136. "spacing": "sm",
  137. "contents": [
  138. {
  139. "type": "text",
  140. "text": "一次到位擁有,只要",
  141. "margin": "none",
  142. "size": "sm",
  143. "gravity": "center",
  144. "color": "#2384e3",
  145. "weight": "bold"
  146. },
  147. {
  148. "type": "text",
  149. "text": "$36,000",
  150. "size": "xxl",
  151. "offsetStart": "5px",
  152. "weight": "bold",
  153. "color": "#2384e3"
  154. }
  155. ],
  156. "backgroundColor": "#fff3ed",
  157. "background": {
  158. "type": "linearGradient",
  159. "angle": "0deg",
  160. "startColor": "#fff3ed",
  161. "endColor": "#ffffff"
  162. }
  163. },
  164. {
  165. "type": "text",
  166. "text": "不論是公司宣傳/產品發表/品牌經營,都能透過新聞稿發布,提升曝光及知名度!",
  167. "wrap": true,
  168. "size": "13px",
  169. "align": "start",
  170. "offsetTop": "10px"
  171. }
  172. ]
  173. },
  174. "footer": {
  175. "type": "box",
  176. "layout": "vertical",
  177. "spacing": "sm",
  178. "contents": [
  179. {
  180. "type": "box",
  181. "layout": "vertical",
  182. "contents": [
  183. {
  184. "type": "button",
  185. "style": "link",
  186. "height": "sm",
  187. "action": {
  188. "type": "uri",
  189. "label": "請來採訪我",
  190. "uri": "https://page.line.me/choozmo"
  191. },
  192. "color": "#FFFFFF"
  193. }
  194. ],
  195. "backgroundColor": "#e47e4d",
  196. "offsetTop": "-3px"
  197. },
  198. {
  199. "type": "box",
  200. "layout": "vertical",
  201. "contents": [
  202. {
  203. "type": "button",
  204. "style": "link",
  205. "height": "sm",
  206. "action": {
  207. "type": "uri",
  208. "label": "了解更多",
  209. "uri": "https://page.line.me/choozmo"
  210. },
  211. "color": "#FFFFFF"
  212. }
  213. ],
  214. "backgroundColor": "#06C152"
  215. }
  216. ],
  217. "flex": 0
  218. }
  219. }
  220. """
  221. data2="""
  222. {
  223. "type": "bubble",
  224. "header": {
  225. "type": "box",
  226. "layout": "vertical",
  227. "contents": [
  228. {
  229. "type": "text",
  230. "text": "集仕多 ChoozMo",
  231. "weight": "bold",
  232. "size": "xl",
  233. "color": "#ffffff"
  234. },
  235. {
  236. "type": "text",
  237. "text": "新聞 AI 主播媒體聯播網最佳方案",
  238. "size": "md",
  239. "color": "#ffffff"
  240. },
  241. {
  242. "type": "box",
  243. "layout": "baseline",
  244. "margin": "md",
  245. "contents": [
  246. {
  247. "type": "icon",
  248. "size": "xxl",
  249. "url": "https://ppt.cc/fLP10x@.png",
  250. "offsetTop": "xs"
  251. }
  252. ],
  253. "justifyContent": "flex-end",
  254. "offsetStart": "255px",
  255. "position": "absolute",
  256. "offsetBottom": "20px"
  257. }
  258. ],
  259. "backgroundColor": "#e1642b"
  260. },
  261. "hero": {
  262. "type": "image",
  263. "url": "https://ppt.cc/fDmzAx@.png",
  264. "size": "full",
  265. "aspectRatio": "20:13",
  266. "offsetTop": "lg"
  267. },
  268. "body": {
  269. "type": "box",
  270. "layout": "vertical",
  271. "contents": [
  272. {
  273. "type": "text",
  274. "text": "圖文+影音+聯播",
  275. "color": "#aaaaaa",
  276. "size": "sm"
  277. },
  278. {
  279. "type": "text",
  280. "text": "全方位媒體曝光,一次到位!",
  281. "color": "#aaaaaa",
  282. "size": "sm"
  283. },
  284. {
  285. "type": "box",
  286. "layout": "baseline",
  287. "margin": "md",
  288. "contents": [
  289. {
  290. "type": "icon",
  291. "size": "md",
  292. "url": "https://ppt.cc/feXZPx@.png",
  293. "offsetTop": "xs"
  294. },
  295. {
  296. "type": "text",
  297. "text": "網路新聞圖文報導",
  298. "offsetStart": "md",
  299. "color": "#e47e4d",
  300. "weight": "bold"
  301. }
  302. ]
  303. },
  304. {
  305. "type": "box",
  306. "layout": "baseline",
  307. "margin": "md",
  308. "contents": [
  309. {
  310. "type": "icon",
  311. "size": "md",
  312. "url": "https://ppt.cc/feXZPx@.png",
  313. "offsetTop": "xs"
  314. },
  315. {
  316. "type": "text",
  317. "text": "十二家網路媒體聯播",
  318. "offsetStart": "md",
  319. "color": "#e47e4d",
  320. "weight": "bold"
  321. }
  322. ]
  323. },
  324. {
  325. "type": "box",
  326. "layout": "baseline",
  327. "margin": "md",
  328. "contents": [
  329. {
  330. "type": "icon",
  331. "size": "md",
  332. "url": "https://ppt.cc/feXZPx@.png",
  333. "offsetTop": "xs"
  334. },
  335. {
  336. "type": "text",
  337. "text": "AI 主播影音播報影片",
  338. "offsetStart": "md",
  339. "color": "#e47e4d",
  340. "weight": "bold"
  341. }
  342. ]
  343. },
  344. {
  345. "type": "box",
  346. "layout": "horizontal",
  347. "margin": "lg",
  348. "spacing": "sm",
  349. "contents": [
  350. {
  351. "type": "text",
  352. "text": "一次到位擁有,只要",
  353. "margin": "none",
  354. "size": "sm",
  355. "gravity": "center",
  356. "color": "#2384e3",
  357. "weight": "bold"
  358. },
  359. {
  360. "type": "text",
  361. "text": "$36,000",
  362. "size": "xxl",
  363. "offsetStart": "5px",
  364. "weight": "bold",
  365. "color": "#2384e3"
  366. }
  367. ],
  368. "backgroundColor": "#fff3ed",
  369. "background": {
  370. "type": "linearGradient",
  371. "angle": "0deg",
  372. "startColor": "#fff3ed",
  373. "endColor": "#ffffff"
  374. }
  375. },
  376. {
  377. "type": "text",
  378. "text": "不論是公司宣傳/產品發表/品牌經營,都能透過新聞稿發布,提升曝光及知名度!",
  379. "wrap": true,
  380. "size": "13px",
  381. "align": "start",
  382. "offsetTop": "10px"
  383. }
  384. ]
  385. },
  386. "footer": {
  387. "type": "box",
  388. "layout": "vertical",
  389. "spacing": "sm",
  390. "contents": [
  391. {
  392. "type": "box",
  393. "layout": "vertical",
  394. "contents": [
  395. {
  396. "type": "button",
  397. "style": "link",
  398. "height": "sm",
  399. "action": {
  400. "type": "uri",
  401. "label": "請來採訪我",
  402. "uri": "https://page.line.me/choozmo"
  403. },
  404. "color": "#FFFFFF"
  405. }
  406. ],
  407. "backgroundColor": "#e47e4d",
  408. "offsetTop": "-3px"
  409. },
  410. {
  411. "type": "box",
  412. "layout": "vertical",
  413. "contents": [
  414. {
  415. "type": "button",
  416. "style": "link",
  417. "height": "sm",
  418. "action": {
  419. "type": "uri",
  420. "label": "了解更多",
  421. "uri": "https://ai.choozmo.com/"
  422. },
  423. "color": "#FFFFFF"
  424. }
  425. ],
  426. "backgroundColor": "#06C152"
  427. },
  428. {
  429. "type": "box",
  430. "layout": "horizontal",
  431. "contents": [
  432. {
  433. "type": "image",
  434. "url": "https://ppt.cc/fHYTTx@.png",
  435. "offsetStart": "35px",
  436. "size": "xl",
  437. "position": "absolute"
  438. },
  439. {
  440. "type": "text",
  441. "text": "技術提供",
  442. "offsetBottom": "15px",
  443. "color": "#8B8B8B",
  444. "size": "sm",
  445. "weight": "bold",
  446. "offsetEnd": "40px",
  447. "position": "absolute"
  448. }
  449. ],
  450. "action": {
  451. "type": "uri",
  452. "label": "action",
  453. "uri": "https://page.line.me/choozmo"
  454. },
  455. "width": "100%",
  456. "height": "50px",
  457. "alignItems": "center",
  458. "offsetTop": "5px"
  459. }
  460. ],
  461. "flex": 0,
  462. "height": "160px"
  463. }
  464. }
  465. """
  466. bubble="""
  467. {
  468. "type": "bubble",
  469. "size": "micro",
  470. "hero": {
  471. "type": "image",
  472. "url": "https://scdn.line-apps.com/n/channel_devcenter/img/flexsnapshot/clip/clip10.jpg",
  473. "size": "full",
  474. "aspectMode": "cover",
  475. "aspectRatio": "320:213"
  476. },
  477. "body": {
  478. "type": "box",
  479. "layout": "vertical",
  480. "contents": [
  481. {
  482. "type": "text",
  483. "text": "{{title }}",
  484. "weight": "bold",
  485. "size": "sm",
  486. "wrap": true
  487. },
  488. {
  489. "type": "box",
  490. "layout": "vertical",
  491. "contents": [
  492. {
  493. "type": "box",
  494. "layout": "baseline",
  495. "spacing": "sm",
  496. "contents": [
  497. {
  498. "type": "text",
  499. "text": "ChoozMo商情AI",
  500. "wrap": true,
  501. "color": "#8c8c8c",
  502. "size": "xs",
  503. "flex": 5
  504. }
  505. ]
  506. }
  507. ]
  508. }]
  509. }
  510. }
  511. """
  512. bubble2="""
  513. {
  514. "type": "bubble",
  515. "header": {
  516. "type": "box",
  517. "layout": "horizontal",
  518. "position": "relative",
  519. "backgroundColor": "#FFFFFFFF",
  520. "contents": [
  521. {
  522. "type": "box",
  523. "layout": "vertical",
  524. "contents": [
  525. {
  526. "type": "image",
  527. "url": "https://i.imgur.com/wQbJeGc.png",
  528. "margin": "none",
  529. "align": "end",
  530. "gravity": "top",
  531. "size": "md",
  532. "aspectRatio": "16:5",
  533. "action": {
  534. "type": "uri",
  535. "label": "ChoozMo",
  536. "uri": "https://cmm.ai/line"
  537. }
  538. },
  539. {
  540. "type": "text",
  541. "text": "今日熱搜",
  542. "weight": "bold",
  543. "color": "#BEB7B7FF",
  544. "position": "absolute",
  545. "offsetTop": "5px",
  546. "contents": []
  547. }
  548. ]
  549. }
  550. ]
  551. },
  552. "hero": {
  553. "type": "image",
  554. "url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_4_news.png",
  555. "size": "full",
  556. "aspectRatio": "20:13",
  557. "aspectMode": "cover",
  558. "action": {
  559. "type": "uri",
  560. "label": "Action",
  561. "uri": "https://linecorp.com/"
  562. }
  563. },
  564. "body": {
  565. "type": "box",
  566. "layout": "horizontal",
  567. "spacing": "md",
  568. "contents": [
  569. {
  570. "type": "spacer"
  571. },
  572. {
  573. "type": "box",
  574. "layout": "vertical",
  575. "contents": [
  576. {
  577. "type": "text",
  578. "text": "A1",
  579. "size": "xs",
  580. "flex": 1,
  581. "gravity": "top",
  582. "contents": []
  583. },
  584. {
  585. "type": "text",
  586. "text": "A2",
  587. "size": "xs",
  588. "flex": 2,
  589. "gravity": "center",
  590. "contents": []
  591. },
  592. {
  593. "type": "text",
  594. "text": "A3",
  595. "size": "xs",
  596. "flex": 2,
  597. "gravity": "center",
  598. "contents": []
  599. },
  600. {
  601. "type": "text",
  602. "text": "A4",
  603. "size": "xs",
  604. "flex": 1,
  605. "gravity": "bottom",
  606. "contents": []
  607. },
  608. {
  609. "type": "spacer"
  610. }
  611. ]
  612. }
  613. ]
  614. },
  615. "footer": {
  616. "type": "box",
  617. "layout": "horizontal",
  618. "contents": [
  619. {
  620. "type": "button",
  621. "action": {
  622. "type": "uri",
  623. "label": "More",
  624. "uri": "https://cmm.ai/line"
  625. }
  626. }
  627. ]
  628. }
  629. }
  630. """
  631. bubble3="""
  632. {
  633. "type": "bubble",
  634. "direction": "ltr",
  635. "header": {
  636. "type": "box",
  637. "layout": "vertical",
  638. "contents": [
  639. {
  640. "type": "box",
  641. "layout": "horizontal",
  642. "action": {
  643. "type": "uri",
  644. "uri": "https://page.line.me/choozmo"
  645. },
  646. "width": "100%",
  647. "contents": [
  648. {
  649. "type": "text",
  650. "text": "今日熱搜",
  651. "align": "start",
  652. "contents": []
  653. },
  654. {
  655. "type": "image",
  656. "url": "https://i.imgur.com/wQbJeGc.png",
  657. "align": "end",
  658. "aspectRatio": "4:1",
  659. "aspectMode": "cover"
  660. }
  661. ]
  662. }
  663. ]
  664. },
  665. "body": {
  666. "type": "box",
  667. "layout": "vertical",
  668. "paddingAll": "0px",
  669. "width": "100%",
  670. "backgroundColor": "#000000FF",
  671. "action": {
  672. "type": "uri",
  673. "uri": "{{ qlink }}"
  674. },
  675. "contents": [
  676. {
  677. "type": "box",
  678. "layout": "vertical",
  679. "contents": [
  680. {
  681. "type": "image",
  682. "url": "{{ imgurl }}",
  683. "size": "full",
  684. "aspectMode": "cover"
  685. },
  686. {
  687. "type": "box",
  688. "layout": "vertical",
  689. "position": "absolute",
  690. "offsetBottom": "0px",
  691. "width": "100%",
  692. "height": "90px",
  693. "backgroundColor": "#9C8E7ECC",
  694. "contents": [
  695. {
  696. "type": "text",
  697. "text": "{{ imgtitle }}",
  698. "color": "#FFFFFFFF",
  699. "align": "start",
  700. "wrap": true,
  701. "contents": []
  702. }
  703. ]
  704. }
  705. ]
  706. },
  707. {
  708. "type": "box",
  709. "layout": "horizontal",
  710. "position": "absolute",
  711. "offsetTop": "10px",
  712. "offsetStart": "5px",
  713. "width": "100px",
  714. "borderWidth": "1px",
  715. "backgroundColor": "#898CDFFF",
  716. "cornerRadius": "5px",
  717. "contents": [
  718. {
  719. "type": "text",
  720. "text": "{{title}}",
  721. "color": "#FFFFFFFF",
  722. "align": "center",
  723. "contents": []
  724. }
  725. ]
  726. }
  727. ]
  728. },
  729. "footer": {
  730. "type": "box",
  731. "layout": "vertical",
  732. "contents": [
  733. {
  734. "type": "text",
  735. "text": "相關關鍵字",
  736. "contents": []
  737. },
  738. {
  739. "type": "separator"
  740. },
  741. {
  742. "type": "box",
  743. "layout": "horizontal",
  744. "contents": [
  745. {
  746. "type": "text",
  747. "text": "{{K1}}",
  748. "contents": []
  749. },
  750. {
  751. "type": "text",
  752. "text": "{{K2}}",
  753. "contents": []
  754. }
  755. ]
  756. },
  757. {
  758. "type": "box",
  759. "layout": "horizontal",
  760. "contents": [
  761. {
  762. "type": "text",
  763. "text": "{{K3}}",
  764. "contents": []
  765. },
  766. {
  767. "type": "text",
  768. "text": "{{K4}}",
  769. "contents": []
  770. }
  771. ]
  772. }
  773. ]
  774. }
  775. }
  776. """
  777. data3_begin="""
  778. {
  779. "type": "carousel",
  780. "contents": [
  781. """
  782. data3_end="""
  783. ]
  784. }
  785. """
  786. import dataset
  787. import json
  788. import sys
  789. #from opengraph import OpenGraph
  790. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/gtrends?charset=utf8mb4')
  791. cursor=db.query('SELECT distinct qtitle FROM gtrends.trending_search_flat order by dt desc limit 5')
  792. qtitles=[]
  793. for c in cursor:
  794. qtitles.append(c['qtitle'])
  795. result=[]
  796. for qt in qtitles:
  797. cursor=db.query('SELECT distinct trending_search_flat.qtitle,trending_search_flat.atitle,trending_search_flat.aimg,trending_search_flat.aurl,kw_related.original,kw_related.kw FROM gtrends.trending_search_flat,kw_related where trending_search_flat.qtitle=kw_related.original and trending_search_flat.qtitle="'+qt+'" order by trending_search_flat.dt desc')
  798. title=None
  799. imgurl=None
  800. imgtitle=qlink=None
  801. k1=k2=k3=k4=None
  802. lst_dict={}
  803. for c in cursor:
  804. title=c['qtitle']
  805. qlink=c['aurl']
  806. imgtitle=c['atitle']
  807. # imgurl=c['aimg']
  808. print(qlink)
  809. if imgurl is None:
  810. try:
  811. video = opengraph.OpenGraph(url=qlink)
  812. if video.is_valid():
  813. if video['image'] is not None:
  814. imgurl=video['image']
  815. print('GET OG IMAGE **************')
  816. print(imgurl)
  817. except:
  818. traceback.print_exc()
  819. imgurl=None
  820. lst_dict[c['kw']]=1
  821. if len(lst_dict)>=4:
  822. break
  823. if imgurl is None:
  824. print('none')
  825. imgurl=c['aimg']
  826. print(lst_dict)
  827. lst=list(lst_dict.keys())
  828. k1=lst[0]
  829. k2=lst[1]
  830. if len(lst)>=3:
  831. k3=lst[2]
  832. else:
  833. k3=' '
  834. if len(lst)>=4:
  835. k4=lst[3]
  836. else:
  837. k4=' '
  838. result.append({'title':title,'imgurl':imgurl,'qlink':qlink,'imgtitle':imgtitle,'K1':k1,'K2':k2,'K3':k3,'K4':k4})
  839. result_lst=result
  840. print(result)
  841. r = redis.Redis(host='db.ptt.cx', port=6379, db=2,password='choozmo9')
  842. rtemplate = Environment(loader=BaseLoader).from_string(bubble3)
  843. result=""
  844. for r2 in result_lst:
  845. # r3 = rtemplate.render({'title':title,'imgurl':imgurl,'qlink':qlink,'imgtitle':imgtitle,'K1':k1,'K2':k2,'K3':k3,'K4':k4})
  846. r3 = rtemplate.render(r2)
  847. result+=r3
  848. result+=','
  849. result=result[:-1]
  850. final_result=data3_begin+result+data3_end
  851. full_result='{"title":"今日熱搜關鍵字","data":'+final_result+'}'
  852. #final_result=data3_begin+result+data3_end
  853. #print(final_result)
  854. #r.set('btn_data',final_result)
  855. r.set('btn_data',full_result)
  856. #r.set('btn_data',data2)
  857. sys.exit()