Github Actions not accessing download from Newspaper3k

63 Views Asked by At

I've been trying to use Github Actions to run a python script. Everything seems to run fine, except a specific function that uses the Newspaper3k package. The article appears to download fine (article.html works ok), but Article.parse() does not work. This works fine on my local server, but not in Github. Is this related to being able to access file locations, that are different on Github? It's a private repository, in case that makes a difference.

My yaml script is as follows:

build:
  runs-on: ubuntu-latest

  steps:
    - name: checkout repo content
      uses: actions/checkout@v3 # checkout the repository content to github runner.
    - name: setup python
      uses: actions/setup-python@v4
      with:
        python-version: '3.10' #install the python needed
        cache: 'pip'
  
    - name: install python packages
      run: |
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

    - name: execute py script # run file
      env: 
        WORDPRESS_USER: ${{ secrets.WORDPRESS_USER }}
        WORDPRESS_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
      run: |
        python main.py

The function in question is provided below:

def generate_article_summary(supplied_links):
    summary_list = ""
    for news_article in supplied_links[:5]:
        try:
            url = news_article
            article = Article(url, config=config)
            article.download()
            article.parse()
            article.nlp()
        except:
            summary_list = summary_list + "\n"
            pass

        summary_list = summary_list + "\n" + article.summary

    return summary_list

Any help would be much appreciated.

0

There are 0 best solutions below