Local test ok, streamlit cloud error| TypeError: This app has encountered an error

app link:https://n46tool.streamlit.app/

I added this APP a few months ago, and the functionality was fine in local testing, as was the streamlit cloud.
But in the past few days, the news-scraping function has reported the following error for https://www.nhk.jp/p/radirer/rs/88w859pyq9/blog/bl/p30z7r1zy2/bp/pyk4x5k9la/

TypeError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you're on Streamlit Cloud, click on 'Manage app' in the lower right of your app).
Traceback:
File "/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 600, in _run_script
    exec(code, module.__dict__)
File "/mount/src/ngztool/N46toolbox.py", line 903, in <module>
    news_catch()
File "/mount/src/ngztool/N46toolbox.py", line 763, in news_catch
    rajira_blog(news_url)
File "/mount/src/ngztool/N46toolbox.py", line 736, in rajira_blog
    title, image_urls = rajira(url)
    ^^^^^^^^^^^^^^^^^

console log:

TypeError: cannot unpack non-iterable NoneType object

────────────────────── Traceback (most recent call last) ───────────────────────

  /home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptru  

  nner/script_runner.py:535 in _run_script                                      

                                                                                

  /mount/src/ngztool/N46toolbox.py:903 in <module>                              

                                                                                

    900 if selected1 == "成员Blog":                                             

    901 │   blog()                                                              

    902 if selected1 == "新闻抓图":                                             

  ❱ 903 │   news_catch()                                                        

    904                                                                         

                                                                                

  /mount/src/ngztool/N46toolbox.py:763 in news_catch                            

                                                                                

    760 │   if 'mdpr' in news_url:                                              

    761 │   │   mdpr(news_url)                                                  

    762 │   if 'www.nhk.jp/p/radirer/' in news_url:                             

  ❱ 763 │   │   rajira_blog(news_url)                                           

    764 │                                                                       

    765 │   if news_url == '':                                                  

    766 │   │   pass                                                            

                                                                                

  /mount/src/ngztool/N46toolbox.py:736 in rajira_blog                           

                                                                                

    733 │   │   st.markdown(img_contnt, unsafe_allow_html=True)                 

    734 │                                                                       

    735 │   def rajira_blog(url):                                               

  ❱ 736 │   │   title, image_urls = rajira(url)                                 

    737 │   │   # 创建压缩文件并下载                                            

    738 │   │   if st.button("下载图片"):                                       

    739 │   │   │   st.info('请稍等,正在将图片处理至压缩包')                    

────────────────────────────────────────────────────────────────────────────────

TypeError: cannot unpack non-iterable NoneType object

I’ve tried other blogs on this site with the same problem.

But in the local test completely no problem, please help you to see what this problem is

Python ver: 3.12.0
Try streamlit ver:1.30.0~1.33.0

These problems occurred in the last few days, before it was completely okay

You forgot to post the actual error message.

edited,Thanks for the reminder

That is because rajira is returning None. What do you want to happen in that case?

Normally,the rajira function itself should return title and image_urls list.
local test is ok , use st.write (image) can also see the list of images.

I added resp.status and resp.reason found that the status code of the output request is found to be 403. I think the traffic sent through the streamlit cloud server be blocked by the site.

Normally. But what if there is no title and no _urls? You need to account for such cases.

I have edited last reply ,seem I found the reason…

Not only this url, the other site’s blog is no longer available, including previously available.

The other mock request methods were successful and were able to get the title and urls.
Localized Streamlit was also successful

It’s not the code; the real problem is that the site blocks the STREAMLIT cloud service from connecting to it

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.