semvec/pypi-packages huggingface dataset:
dockercontext 0.1
Run Docker containers within Python context manager
Requires Python: >=3.8

# Docker Context
Run containers using `with` statement. 
## Example
```python
import unittest
from urllib import request

from dockercontext import container


class ContextTest(unittest.TestCase):

    def test_response(self):
        with container.Context("nginx:alpine", {"80/tcp": 8080}):
            with request.urlopen("http://localhost:8080/") as response:
                self.assertEqual(response.code, 200)

    def test_container_id(self):
        with container.Context("nginx:alpine", {}) as ctx:
            self.assertEqual(64, len(ctx.container_id()))

        self.assertEqual(0, len(ctx.container_id()), ctx.container_id())
```
Note that although context blocks until container's state is `running` this does not meant that service inside container is ready. 

## Tests
`$ python -m unittest`
twitsearch 1.1.1
A Package related to Twitter API , providing Way to fetch a user's tweets and printing thier content. More Features Coming Soon.
Requires Python: >=3.6

# Let's install the module first.
We need to install 2 Modules, Tweepy and twitsearch itself, so...
```python
pip install twitsearch
AND
pip install tweepy
```
We are installing tweepy because the modules runs on the tweepy Module which is used to get the Twitter API.

# Now import  twitsearch
```python
from twitsearch
``` 

# Searching a twitter account's name and getting a specific amount of tweets.
```python
search = twitsearch.accesstwitsearch()
result = search.search_username("FortniteGame",5) #FortniteGame is the twitter account's username and 5 is the amount of tweets you want from the result. The username doesn't need the @.
``` 
The upper code will search for the user in twitter and if the user is found it will return a bunch of a attributes. 

```python
for i in result: #The result is a list containing the tweets so we have to loop through it.
    print(i.full_text)
    print(i.favorite_count, i.retweet_count)
```
This will print the text and the number of likes and retweets and yes it will print the Latest tweets sent by the user.
Attributes that `search_username` returns.
```
created_at
favorite_count : Likes
full_text : Gives text
id
retweet_count : Retweet
source : Tell that on which device the tweet was sent like an Iphone or Samsung
```


# Retweet picker
```python
retweetpicker = twitsearch.accesstwitsearch()
choose = retweetpicker.choose_user(1337983288661557248)
print(f'Chosen user - {choose.name}')
```
Using the above code you can choose a random person from a tweet and reveal it's name or id by the Attributes that choose_user returns, you need to write the Tweet/Status ID in the Parenthesis of `choose_user`

Attributes that `choose_user` returns
```
username : Returns the @ of the user
name : Returns the name of the user
id
created_at
desciption
followers
following
```

# More Features coming soon...
nscrap 0.0.4
Articles notification by scheduled web scrapers
Requires Python: >=3.7

# nscrap
주기적으로 Scraper 를 실행하여 기사제목에 특정 키워드가 포함되면 Messenger 를 통해 알림을 발송합니다  

# Installation
```
pip install nscrap
```
Or
```
git clone https://github.com/pparkddo/nscrap.git
pip install -r requirements.txt
```

# Usage

```python
from datetime import datetime

import requests
from bs4 import BeautifulSoup

from nscrap.scraper import ArticleScraper, ArticleConnectionError, ArticleParsingError, Article
from nscrap.runner import ScraperRunner
from nscrap.messenger import TelegramMessenger
from nscrap.press import Press
from nscrap.keywords import Keyword


# Define Scraper
class HkScraper(ArticleScraper):

    def __init__(self):
        self.url = "https://www.hankyung.com/all-news/"

    def get_press_name(self):
        return "한국경제"

    def get_articles(self):
        response = self._get_response()
        parsed = self._parse_articles(response)
        return [
            Article(title=each.text, link=each["href"], timestamp=datetime.now())
            for each in parsed
        ]

    def _get_response(self):
        try:
            return requests.get(self.url)
        except Exception as err:
            raise ArticleConnectionError(f"{self.get_press_name()} scraper requests error") from err

    def _parse_articles(self, response):
        try:
            soup = BeautifulSoup(response.text, "html.parser")
            title_classes = soup.find_all(class_="tit")
            return [title_class.find("a") for title_class in title_classes]
        except Exception as err:
            raise ArticleParsingError(f"{self.get_press_name()} scraper parsing error") from err


# 'telegram-bot-token': 텔레그램에서 발행한 봇토큰을 입력
# 123456789: 메시지를 보낼 대화방 ID
messenger = TelegramMessenger("telegram-bot-token", 123456789)

press = [
    Press("한국경제", True, 30),
]

keywords = [
    Keyword("백신"),
    Keyword("정부"),
]

scrapers = [
    HkScraper(),
]

runner = ScraperRunner(messenger)
runner.add_press(press)
runner.add_keyword(keywords)
runner.add_scraper(scrapers)
runner.start()  # ctrl+c 를 입력하면 스케쥴러 종료
```
Output
```
[+] Send validation message from nscrap
[+] Test succeed: 한국경제 passed test
press: [Press(press_name='한국경제', active=True, delay=30)]
keywords: ['정부', '백신']
scrapers: ['한국경제']
[+] Start nscrap
[+] Start 한국경제 scraper at 2020-12-12 23:23:12
[+] Scrap 기사제목(https://www.hankyung.com/기사링크)
[+] Start 한국경제 scraper at 2020-12-12 23:23:42
...
[+] Stop nscrap
```

# Customization
* nscrap.scraper.ArticleScraper 를 상속하여 여러 scraper 구현 가능
* nscrap.messenger.Messenger 를 상속하여 다양한 메신저 구현가능
* nscrap.container.ArticleContainer 를 상속하여 ArticleRunner 내부에서 사용할 article 저장소 구현가능