cfp1 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
cfp1-0.1/MANIFEST.in ADDED
@@ -0,0 +1 @@
1
+ include cfp1/data.txt
cfp1-0.1/PKG-INFO ADDED
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: cfp1
3
+ Version: 0.1
@@ -0,0 +1,2 @@
1
+ from importlib.resources import files
2
+ print(files("cfp1").joinpath("data.txt").read_text())
cfp1-0.1/cfp1/data.txt ADDED
@@ -0,0 +1,98 @@
1
+ #Practical 1:Web Scraping in Social media
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+
5
+ url = "https://example.com"
6
+
7
+ try:
8
+ response = requests.get(url)
9
+ response.raise_for_status()
10
+ soup = BeautifulSoup(response.text, "html.parser")
11
+ paragraphs = soup.find_all('p')
12
+ print(f"Found {len(paragraphs)} paragraphs:")
13
+ for para in paragraphs:
14
+ print(f"- {para.get_text().strip()}")
15
+
16
+ title = soup.find('title')
17
+ if title:
18
+ print(f"\nPage Title:{title.get_text().strip()}")
19
+
20
+ except requests.exceptions.RequestException as e:
21
+ print(f"An error occurred during the request: {e}")
22
+
23
+ except Exception as e:
24
+ print(f"An unexpected error occurred: {e}")
25
+
26
+
27
+
28
+ #2 Twitter
29
+
30
+ import numpy as np
31
+ import pandas as pd
32
+ import matplotlib.pyplot as plt
33
+ from tweeterpy import TweeterPy
34
+ from tweeterpy.util import User, Tweet
35
+ from pandas import json_normalize
36
+ import json
37
+
38
+ twitter = TweeterPy()
39
+ data = twitter.search("IPL")
40
+
41
+ combined_data = []
42
+
43
+ for tweet_data in data['data'][1:]: # Start from index 1 to skip header if present
44
+ try:
45
+ tweet = Tweet(tweet_data)
46
+ user_data = twitter.get_user_data(tweet.dict()['screen_name'])
47
+
48
+ flattened_tweet_data = json_normalize(tweet.dict())
49
+ flattened_user_data = json_normalize(user_data)
50
+
51
+ combined_data_row = {
52
+ **flattened_tweet_data.to_dict(orient='records')[0],
53
+ **flattened_user_data.to_dict(orient='records')[0]
54
+ }
55
+
56
+ combined_data.append(combined_data_row)
57
+
58
+ except Exception as e:
59
+ print(f"Error processing tweet {tweet_data.get('id')}: {e}")
60
+
61
+ df = pd.DataFrame(combined_data)
62
+ df.info()
63
+
64
+ source_counts = df['source'].value_counts()
65
+
66
+ plt.figure(figsize=(10, 6))
67
+ source_counts.plot(kind='pie', autopct='%1.1f%%', startangle=140)
68
+ plt.title('Distribution of Tweet Sources')
69
+ plt.axis('equal')
70
+ plt.tight_layout()
71
+ plt.show()
72
+
73
+ tweets_per_user = df['screen_name'].value_counts().head(10)
74
+
75
+ plt.figure(figsize=(10, 6))
76
+ tweets_per_user.plot(kind='bar', color='skyblue')
77
+ plt.title('Top 10 Users by Number of Tweets')
78
+ plt.xlabel('User Name')
79
+ plt.ylabel('Number of Tweets')
80
+ plt.xticks(rotation=45, ha='right')
81
+ plt.tight_layout()
82
+ plt.show()
83
+
84
+ df['legacy.created_at'] = pd.to_datetime(df['legacy.created_at'], errors='coerce')
85
+ df['user_creation_year'] = df['legacy.created_at'].dt.year
86
+
87
+ df.dropna(subset=['user_creation_year'], inplace=True)
88
+
89
+ user_creation_counts = df['user_creation_year'].value_counts().sort_index()
90
+
91
+ plt.figure(figsize=(10, 6))
92
+ user_creation_counts.plot(kind='bar', color='skyblue')
93
+ plt.title('User Creation Year-wise')
94
+ plt.xlabel('Year')
95
+ plt.ylabel('Number of Users Created')
96
+ plt.xticks(rotation=45)
97
+ plt.tight_layout()
98
+ plt.show()
@@ -0,0 +1,3 @@
1
+ Metadata-Version: 2.4
2
+ Name: cfp1
3
+ Version: 0.1
@@ -0,0 +1,9 @@
1
+ MANIFEST.in
2
+ pyproject.toml
3
+ setup.py
4
+ cfp1/__init__.py
5
+ cfp1/data.txt
6
+ cfp1.egg-info/PKG-INFO
7
+ cfp1.egg-info/SOURCES.txt
8
+ cfp1.egg-info/dependency_links.txt
9
+ cfp1.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ cfp1
@@ -0,0 +1,3 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
cfp1-0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
cfp1-0.1/setup.py ADDED
@@ -0,0 +1,9 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="cfp1",
5
+ version="0.1",
6
+ packages=find_packages(),
7
+ include_package_data=True,
8
+ package_data={"cfp1": ["data.txt"]},
9
+ )