Skip to content

Latest commit

 

History

History
474 lines (441 loc) · 14.7 KB

File metadata and controls

474 lines (441 loc) · 14.7 KB

Title: UpMob API with Web-Scraping

1. Methodology (High Level)

Methodology

2. Description

UpMob API scraps 91mobiles.com to get devices information which are yet to be released in the Indian market and stores it in a Postgres Database. The data is served by one of the endpoint. Client applications like UpMob App can use and represent the data.

3. Input/Output

Input:

Output:

  • Success Response:

    • Code: 200

      See Response
      [
        {
              "device_name": "OnePlus 8T Pro",
              "last_updated": "Updated on: Jul 26, 2021",
              "expected": "August 7, 2021 (Unofficial)",
              "price": 57999,
              "img_url": "https://www.91-img.com/pictures/139350-v1-oneplus-8t-pro-mobile-phone-large-1.jpg?tr=q-60",
              "source_url": "https://www.91mobiles.com/oneplus-8t-pro-price-in-india",
              "spec_score": 0,
              "ram": {
                  "String": "8 GB",
                  "Valid": true
              },
              "processor": {
                  "String": "Qualcomm Snapdragon 865 Plus",
                  "Valid": true
              },
              "front_camera": {
                  "String": "16 MP",
                  "Valid": true
              },
              "rear_camera": {
                  "String": "64 MP + 48 MP + 8 MP + 5 MP",
                  "Valid": true
              },
              "battery": {
                  "String": "4850 mAh",
                  "Valid": true
              },
              "display": {
                  "String": "6.78 inches",
                  "Valid": true
              },
              "operating_system": {
                  "String": "Android v10 (Q)",
                  "Valid": true
              },
              "custom_ui": {
                  "String": "Oxygen OS",
                  "Valid": true
              },
              "chipset": {
                  "String": "Qualcomm Snapdragon 865 Plus",
                  "Valid": true
              },
              "cpu": {
                  "String": "Octa core (3.09 GHz, Single core, Kryo 585 + 2.42 GHz, Tri core, Kryo 585 + 1.8 GHz, Quad core, Kryo 585)",
                  "Valid": true
              },
              "architecture": {
                  "String": "64 bit",
                  "Valid": true
              },
              "graphics": {
                  "String": "Adreno 650",
                  "Valid": true
              },
              "display_type": {
                  "String": "Fluid AMOLED",
                  "Valid": true
              },
              "screen_size": {
                  "String": "6.78 inches (17.22 cm)",
                  "Valid": true
              },
              "resolution": {
                  "String": "1440 x 3168 pixels",
                  "Valid": true
              },
              "pixel_density": {
                  "String": "513 ppi",
                  "Valid": true
              },
              "touchscreen": {
                  "String": "Yes, Capacitive Touchscreen, Multi-touch",
                  "Valid": true
              },
              "internal_memory": {
                  "String": "256 GB",
                  "Valid": true
              },
              "expandable_memory": {
                  "String": "No",
                  "Valid": true
              },
              "m_camera_setup": {
                  "String": "Quad",
                  "Valid": true
              },
              "m_resolution": {
                  "String": "64 MP Primary Camera48 MP, Wide Angle, Ultra-Wide Angle Camera8 MP Telephoto Camera5 MP Camera",
                  "Valid": true
              },
              "m_autofocus": {
                  "String": "Yes, Phase Detection autofocus",
                  "Valid": true
              },
              "m_ois": {
                  "String": "Yes",
                  "Valid": true
              },
              "m_sensors": {
                  "String": "",
                  "Valid": false
              },
              "m_flash": {
                  "String": "Yes, LED Flash",
                  "Valid": true
              },
              "m_image_resolution": {
                  "String": "",
                  "Valid": false
              },
              "m_settings": {
                  "String": "Exposure compensation, ISO control",
                  "Valid": true
              },
              "m_shooting_modes": {
                  "String": "Continuos ShootingHigh Dynamic Range mode (HDR)",
                  "Valid": true
              },
              "m_camera_features": {
                  "String": "Digital ZoomAuto FlashFace detectionTouch to focus",
                  "Valid": true
              },
              "m_video_recording": {
                  "String": "",
                  "Valid": false
              },
              "s_camera_setup": {
                  "String": "Single",
                  "Valid": true
              },
              "s_resolution": {
                  "String": "16 MP Primary Camera",
                  "Valid": true
              },
              "s_video_recording": {
                  "String": "",
                  "Valid": false
              },
              "capacity": {
                  "String": "4850 mAh",
                  "Valid": true
              },
              "removable_battery": {
                  "String": "No",
                  "Valid": true
              },
              "wireless_charging": {
                  "String": "",
                  "Valid": false
              },
              "quick_charging": {
                  "String": "Yes, Fast",
                  "Valid": true
              },
              "usb": {
                  "String": "Yes",
                  "Valid": true
              },
              "sim_slots": {
                  "String": "Dual SIM, GSM+GSM",
                  "Valid": true
              },
              "network_support": {
                  "String": "5G supported by device (network not rolled-out in India), 4G (supports Indian bands), 3G, 2G",
                  "Valid": true
              },
              "fingerprint_sensor": {
                  "String": "Yes",
                  "Valid": true
              },
              "other_sensors": {
                  "String": "Light sensor, Proximity sensor, Accelerometer, Compass, Gyroscope",
                  "Valid": true
              },
              "scrape_timestamp": "2021-07-25T21:33:31.655995Z"
          }, ... ]
      

4. Live Link

Deployment Link: https://upmob.koreacentral.cloudapp.azure.com/

5. Screenshots

Homepage API-endpoint



x-----------------------------------------------------------------------------------------------------x
x-----------------------------------------------------------------------------------------------------x

📱🔍 upcoming_mobiles_api (UpMob API)

UpMob API scraps 91mobiles.com to get devices information which are yet to be released in the Indian market and stores it in a postgres db

✨ Features

  1. Web Scraper
  2. Cron Scheduler scrapes data every 24 hours
  3. Static scraping by calling internal AJAX calls
  4. Database Migrations
  5. Usage of Docker(Containerization) and Maketool(automation)
  6. Code for testing with good test coverage

📚 API

Fetch all upcoming devices

  • URL

    /devices/top100

  • Method

    GET

  • URL Params

    None

  • Success Response:

    • Code: 200

      See Response
      [
        {
              "device_name": "OnePlus 8T Pro",
              "last_updated": "Updated on: Jul 26, 2021",
              "expected": "August 7, 2021 (Unofficial)",
              "price": 57999,
              "img_url": "https://www.91-img.com/pictures/139350-v1-oneplus-8t-pro-mobile-phone-large-1.jpg?tr=q-60",
              "source_url": "https://www.91mobiles.com/oneplus-8t-pro-price-in-india",
              "spec_score": 0,
              "ram": {
                  "String": "8 GB",
                  "Valid": true
              },
              "processor": {
                  "String": "Qualcomm Snapdragon 865 Plus",
                  "Valid": true
              },
              "front_camera": {
                  "String": "16 MP",
                  "Valid": true
              },
              "rear_camera": {
                  "String": "64 MP + 48 MP + 8 MP + 5 MP",
                  "Valid": true
              },
              "battery": {
                  "String": "4850 mAh",
                  "Valid": true
              },
              "display": {
                  "String": "6.78 inches",
                  "Valid": true
              },
              "operating_system": {
                  "String": "Android v10 (Q)",
                  "Valid": true
              },
              "custom_ui": {
                  "String": "Oxygen OS",
                  "Valid": true
              },
              "chipset": {
                  "String": "Qualcomm Snapdragon 865 Plus",
                  "Valid": true
              },
              "cpu": {
                  "String": "Octa core (3.09 GHz, Single core, Kryo 585 + 2.42 GHz, Tri core, Kryo 585 + 1.8 GHz, Quad core, Kryo 585)",
                  "Valid": true
              },
              "architecture": {
                  "String": "64 bit",
                  "Valid": true
              },
              "graphics": {
                  "String": "Adreno 650",
                  "Valid": true
              },
              "display_type": {
                  "String": "Fluid AMOLED",
                  "Valid": true
              },
              "screen_size": {
                  "String": "6.78 inches (17.22 cm)",
                  "Valid": true
              },
              "resolution": {
                  "String": "1440 x 3168 pixels",
                  "Valid": true
              },
              "pixel_density": {
                  "String": "513 ppi",
                  "Valid": true
              },
              "touchscreen": {
                  "String": "Yes, Capacitive Touchscreen, Multi-touch",
                  "Valid": true
              },
              "internal_memory": {
                  "String": "256 GB",
                  "Valid": true
              },
              "expandable_memory": {
                  "String": "No",
                  "Valid": true
              },
              "m_camera_setup": {
                  "String": "Quad",
                  "Valid": true
              },
              "m_resolution": {
                  "String": "64 MP Primary Camera48 MP, Wide Angle, Ultra-Wide Angle Camera8 MP Telephoto Camera5 MP Camera",
                  "Valid": true
              },
              "m_autofocus": {
                  "String": "Yes, Phase Detection autofocus",
                  "Valid": true
              },
              "m_ois": {
                  "String": "Yes",
                  "Valid": true
              },
              "m_sensors": {
                  "String": "",
                  "Valid": false
              },
              "m_flash": {
                  "String": "Yes, LED Flash",
                  "Valid": true
              },
              "m_image_resolution": {
                  "String": "",
                  "Valid": false
              },
              "m_settings": {
                  "String": "Exposure compensation, ISO control",
                  "Valid": true
              },
              "m_shooting_modes": {
                  "String": "Continuos ShootingHigh Dynamic Range mode (HDR)",
                  "Valid": true
              },
              "m_camera_features": {
                  "String": "Digital ZoomAuto FlashFace detectionTouch to focus",
                  "Valid": true
              },
              "m_video_recording": {
                  "String": "",
                  "Valid": false
              },
              "s_camera_setup": {
                  "String": "Single",
                  "Valid": true
              },
              "s_resolution": {
                  "String": "16 MP Primary Camera",
                  "Valid": true
              },
              "s_video_recording": {
                  "String": "",
                  "Valid": false
              },
              "capacity": {
                  "String": "4850 mAh",
                  "Valid": true
              },
              "removable_battery": {
                  "String": "No",
                  "Valid": true
              },
              "wireless_charging": {
                  "String": "",
                  "Valid": false
              },
              "quick_charging": {
                  "String": "Yes, Fast",
                  "Valid": true
              },
              "usb": {
                  "String": "Yes",
                  "Valid": true
              },
              "sim_slots": {
                  "String": "Dual SIM, GSM+GSM",
                  "Valid": true
              },
              "network_support": {
                  "String": "5G supported by device (network not rolled-out in India), 4G (supports Indian bands), 3G, 2G",
                  "Valid": true
              },
              "fingerprint_sensor": {
                  "String": "Yes",
                  "Valid": true
              },
              "other_sensors": {
                  "String": "Light sensor, Proximity sensor, Accelerometer, Compass, Gyroscope",
                  "Valid": true
              },
              "scrape_timestamp": "2021-07-25T21:33:31.655995Z"
          }, ... ]
      

🚀 Get Started with the Installation

  1. Required Installations
    1. Install GoLang in your system
    2. Install Docker in your system
    3. Install Golang Migrate Tool
    4. Make sure you have make tool installed.
  2. Navigate into the project directory
  3. Run
       go mod download
       make postgres
       make createdb
       make migrateup 
    This sets up and runs your postgres container, creates db in it and migrates database.
  4. Run
        make server
    This runs main.go and you are good to Go 😉

💜 Development and Contributing

Yes, please! Feel free to contribute, raise issues and recommend best practices. Makefile is your friend.

A few resources: