File size: 67,169 Bytes
a3766cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Legal WebScraper Pro | Area Code Focused Data Extraction</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Source+Code+Pro:wght@400;600&family=Libre+Baskerville:wght@400;700&display=swap');
        
        body {
            font-family: 'Libre Baskerville', serif;
            background-color: #f8fafc;
            color: #1e293b;
        }
        
        .code-font {
            font-family: 'Source Code Pro', monospace;
        }
        
        .header-gradient {
            background: linear-gradient(135deg, #1e40af 0%, #7c3aed 100%);
        }
        
        .progress-bar {
            height: 6px;
            background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
            transition: width 0.3s ease;
        }
        
        .data-card {
            transition: all 0.3s ease;
            border-left: 4px solid transparent;
        }
        
        .data-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
            border-left-color: #4f46e5;
        }
        
        .file-upload {
            border: 2px dashed #cbd5e1;
            transition: all 0.3s ease;
        }
        
        .file-upload:hover {
            border-color: #818cf8;
            background-color: #f1f5f9;
        }
        
        .file-upload.dragover {
            border-color: #4f46e5;
            background-color: #e0e7ff;
        }
        
        .spinner {
            animation: spin 1s linear infinite;
        }
        
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        .tab-active {
            border-bottom: 3px solid #4f46e5;
            color: #4f46e5;
            font-weight: 600;
        }
        
        .tooltip {
            position: relative;
        }
        
        .tooltip-text {
            visibility: hidden;
            width: 200px;
            background-color: #1e293b;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -100px;
            opacity: 0;
            transition: opacity 0.3s;
        }
        
        .tooltip:hover .tooltip-text {
            visibility: visible;
            opacity: 1;
        }
    </style>
</head>
<body class="min-h-screen">
    <!-- Header -->
    <header class="header-gradient text-white shadow-lg">
        <div class="container mx-auto px-4 py-6">
            <div class="flex justify-between items-center">
                <div>
                    <h1 class="text-3xl font-bold">Legal WebScraper Pro</h1>
                    <p class="mt-2 opacity-90">Area Code Focused Data Extraction Tool</p>
                </div>
                <div class="flex items-center space-x-4">
                    <div class="tooltip">
                        <button class="p-2 rounded-full bg-indigo-700 hover:bg-indigo-600 transition">
                            <i class="fas fa-question"></i>
                        </button>
                        <span class="tooltip-text">This tool complies with ethical scraping guidelines and respects robots.txt</span>
                    </div>
                    <button id="exportBtn" class="hidden px-4 py-2 bg-white text-indigo-700 rounded-lg font-medium hover:bg-gray-100 transition">
                        <i class="fas fa-file-export mr-2"></i>Export Data
                    </button>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="container mx-auto px-4 py-8">
        <!-- Configuration Panel -->
        <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-6">Scraper Configuration</h2>
                
                <!-- Tabs -->
                <div class="border-b border-gray-200 mb-6">
                    <div class="flex space-x-8">
                        <button id="manualTab" class="tab-active pb-3 px-1 text-sm font-medium">Manual Input</button>
                        <button id="fileTab" class="pb-3 px-1 text-sm font-medium text-gray-500 hover:text-gray-700">File Upload</button>
                        <button id="aggregatorTab" class="pb-3 px-1 text-sm font-medium text-gray-500 hover:text-gray-700">URL Aggregator</button>
                    </div>
                </div>
                
                <!-- Area Code Input -->
                <div class="mb-6">
                    <label for="areaCode" class="block text-sm font-medium text-gray-700 mb-2">Target Area Code</label>
                    <div class="mt-1 relative rounded-md shadow-sm max-w-xs">
                        <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                            <span class="text-gray-500 sm:text-sm">#</span>
                        </div>
                        <input type="text" name="areaCode" id="areaCode" 
                            class="focus:ring-indigo-500 focus:border-indigo-500 block w-full pl-7 pr-12 py-2 sm:text-sm border-gray-300 rounded-md" 
                            placeholder="e.g. 90210" maxlength="5">
                        <div class="absolute inset-y-0 right-0 flex items-center">
                            <label for="countryCode" class="sr-only">Country</label>
                            <select id="countryCode" class="focus:ring-indigo-500 focus:border-indigo-500 h-full py-0 pl-2 pr-7 border-transparent bg-transparent text-gray-500 sm:text-sm rounded-md">
                                <option>US +1</option>
                                <option>UK +44</option>
                                <option>CA +1</option>
                                <option>AU +61</option>
                            </select>
                        </div>
                    </div>
                    <p id="areaCodeError" class="mt-1 text-sm text-red-600 hidden">Please enter a valid area code (3-5 digits)</p>
                </div>
                
                <!-- Manual Input Tab Content -->
                <div id="manualContent" class="space-y-6">
                    <div>
                        <label for="urlInput" class="block text-sm font-medium text-gray-700 mb-2">Website URLs (one per line)</label>
                        <textarea id="urlInput" rows="5" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md"></textarea>
                        <div class="mt-2 flex justify-end">
                            <button id="addSampleBtn" class="inline-flex items-center px-3 py-1 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none">
                                <i class="fas fa-vial mr-1"></i> Add Sample URLs
                            </button>
                        </div>
                    </div>
                </div>
                
                <!-- File Upload Tab Content -->
                <div id="fileContent" class="hidden space-y-6">
                    <div class="file-upload rounded-lg p-8 text-center cursor-pointer" id="dropZone">
                        <input type="file" id="fileInput" class="hidden" accept=".txt,.csv">
                        <div class="flex flex-col items-center justify-center">
                            <i class="fas fa-cloud-upload-alt text-4xl text-gray-400 mb-3"></i>
                            <p class="text-sm text-gray-600 mb-1">Drag & drop your URLs file here</p>
                            <p class="text-xs text-gray-500">or</p>
                            <label for="fileInput" class="mt-2 px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 cursor-pointer">
                                Browse Files
                            </label>
                        </div>
                        <div id="fileInfo" class="mt-4 hidden">
                            <p class="text-sm font-medium text-gray-700"><i class="fas fa-file-alt mr-2"></i><span id="fileName"></span></p>
                            <p class="text-xs text-gray-500 mt-1"><span id="fileSize"></span> | <span id="fileType"></span></p>
                        </div>
                    </div>
                </div>
                
                <!-- URL Aggregator Tab Content -->
                <div id="aggregatorContent" class="hidden space-y-6">
                    <div>
                        <label for="searchTopic" class="block text-sm font-medium text-gray-700 mb-2">Search Topic/Keywords</label>
                        <input type="text" id="searchTopic" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md" placeholder="e.g. public records, business listings">
                    </div>
                    <div>
                        <label for="resultLimit" class="block text-sm font-medium text-gray-700 mb-2">Maximum Results</label>
                        <select id="resultLimit" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md">
                            <option value="10">10</option>
                            <option value="20" selected>20</option>
                            <option value="30">30</option>
                            <option value="50">50</option>
                        </select>
                    </div>
                    <div class="flex items-center">
                        <input id="includeGovCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                        <label for="includeGovCheck" class="ml-2 block text-sm text-gray-700">Include government sources (.gov)</label>
                    </div>
                    <div class="flex items-center">
                        <input id="includeEduCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                        <label for="includeEduCheck" class="ml-2 block text-sm text-gray-700">Include educational sources (.edu)</label>
                    </div>
                </div>
                
                <!-- National Databases Section -->
                <div class="mt-8 pt-6 border-t border-gray-200">
                    <div class="flex items-center justify-between mb-4">
                        <h3 class="text-lg font-medium text-gray-900">National Databases</h3>
                        <button id="toggleDbBtn" class="text-sm text-indigo-600 hover:text-indigo-500">Select All</button>
                    </div>
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div class="flex items-center">
                            <input id="censusCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                            <label for="censusCheck" class="ml-2 block text-sm text-gray-700">US Census Bureau</label>
                        </div>
                        <div class="flex items-center">
                            <input id="fccCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                            <label for="fccCheck" class="ml-2 block text-sm text-gray-700">FCC Area Code Data</label>
                        </div>
                        <div class="flex items-center">
                            <input id="uspsCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                            <label for="uspsCheck" class="ml-2 block text-sm text-gray-700">USPS Zip Code Data</label>
                        </div>
                        <div class="flex items-center">
                            <input id="dunsCheck" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
                            <label for="dunsCheck" class="ml-2 block text-sm text-gray-700">DUNS Business Registry</label>
                        </div>
                    </div>
                </div>
                
                <!-- Advanced Options -->
                <div class="mt-8 pt-6 border-t border-gray-200">
                    <div class="flex items-center justify-between mb-4">
                        <h3 class="text-lg font-medium text-gray-900">Advanced Options</h3>
                        <button id="toggleAdvancedBtn" class="text-sm text-indigo-600 hover:text-indigo-500">Show</button>
                    </div>
                    <div id="advancedOptions" class="hidden space-y-4">
                        <div>
                            <label for="requestDelay" class="block text-sm font-medium text-gray-700 mb-1">Request Delay (seconds)</label>
                            <input type="range" id="requestDelay" min="1" max="10" value="3" class="w-full">
                            <div class="flex justify-between text-xs text-gray-500 mt-1">
                                <span>1s (Fast)</span>
                                <span id="delayValue">3s</span>
                                <span>10s (Slow)</span>
                            </div>
                        </div>
                        <div class="flex items-center">
                            <input id="respectRobots" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded" checked>
                            <label for="respectRobots" class="ml-2 block text-sm text-gray-700">Respect robots.txt</label>
                        </div>
                        <div class="flex items-center">
                            <input id="jsRendering" type="checkbox" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
                            <label for="jsRendering" class="ml-2 block text-sm text-gray-700">Enable JavaScript rendering (slower)</label>
                        </div>
                        <div>
                            <label for="userAgent" class="block text-sm font-medium text-gray-700 mb-1">Custom User Agent</label>
                            <select id="userAgent" class="shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md">
                                <option value="default">Default (Mozilla/5.0)</option>
                                <option value="googlebot">Googlebot</option>
                                <option value="bingbot">Bingbot</option>
                                <option value="custom">Custom...</option>
                            </select>
                            <input id="customUserAgent" type="text" class="mt-2 shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border border-gray-300 rounded-md hidden" placeholder="Enter custom user agent">
                        </div>
                    </div>
                </div>
                
                <!-- Action Buttons -->
                <div class="mt-8 flex flex-col sm:flex-row sm:justify-between space-y-4 sm:space-y-0 sm:space-x-4">
                    <button id="clearBtn" class="px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none">
                        <i class="fas fa-eraser mr-2"></i>Clear Form
                    </button>
                    <button id="startBtn" class="px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none">
                        <i class="fas fa-play mr-2"></i>Start Scraping
                    </button>
                </div>
            </div>
        </div>
        
        <!-- Progress Section -->
        <div id="progressSection" class="bg-white rounded-xl shadow-md overflow-hidden mb-8 hidden">
            <div class="p-6">
                <h2 class="text-2xl font-bold text-gray-800 mb-4">Scraping Progress</h2>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Status: <span id="statusText" class="font-medium">Initializing</span></span>
                        <span id="progressText">0%</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2.5">
                        <div id="progressBar" class="progress-bar h-2.5 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
                <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-4">
                    <div class="bg-gray-50 p-3 rounded-lg">
                        <p class="text-xs text-gray-500">URLs Processed</p>
                        <p class="text-lg font-semibold"><span id="processedCount">0</span>/<span id="totalCount">0</span></p>
                    </div>
                    <div class="bg-gray-50 p-3 rounded-lg">
                        <p class="text-xs text-gray-500">Data Points</p>
                        <p class="text-lg font-semibold" id="dataPoints">0</p>
                    </div>
                    <div class="bg-gray-50 p-3 rounded-lg">
                        <p class="text-xs text-gray-500">Errors</p>
                        <p class="text-lg font-semibold text-red-600" id="errorCount">0</p>
                    </div>
                    <div class="bg-gray-50 p-3 rounded-lg">
                        <p class="text-xs text-gray-500">Time Elapsed</p>
                        <p class="text-lg font-semibold" id="timeElapsed">00:00</p>
                    </div>
                </div>
                <div class="border-t border-gray-200 pt-4">
                    <h3 class="text-sm font-medium text-gray-700 mb-2">Activity Log</h3>
                    <div id="activityLog" class="bg-gray-50 p-3 rounded-lg max-h-40 overflow-y-auto text-sm code-font">
                        <div class="text-gray-500">System initialized and ready...</div>
                    </div>
                </div>
                <div class="mt-4 flex justify-end">
                    <button id="stopBtn" class="px-4 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-red-600 hover:bg-red-700 focus:outline-none">
                        <i class="fas fa-stop mr-2"></i>Stop Scraping
                    </button>
                </div>
            </div>
        </div>
        
        <!-- Results Section -->
        <div id="resultsSection" class="hidden">
            <div class="flex justify-between items-center mb-6">
                <h2 class="text-2xl font-bold text-gray-800">Scraping Results</h2>
                <div class="flex space-x-3">
                    <button id="exportCsvBtn" class="px-3 py-1 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
                        <i class="fas fa-file-csv mr-1"></i>CSV
                    </button>
                    <button id="exportJsonBtn" class="px-3 py-1 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
                        <i class="fas fa-file-code mr-1"></i>JSON
                    </button>
                    <button id="exportPdfBtn" class="px-3 py-1 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
                        <i class="fas fa-file-pdf mr-1"></i>PDF
                    </button>
                </div>
            </div>
            
            <!-- Summary Cards -->
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
                <div class="data-card bg-white p-6 rounded-lg shadow-sm">
                    <div class="flex items-center mb-3">
                        <div class="p-2 rounded-full bg-blue-100 text-blue-600 mr-3">
                            <i class="fas fa-link"></i>
                        </div>
                        <h3 class="text-lg font-medium">Sources Processed</h3>
                    </div>
                    <p class="text-3xl font-bold mb-2" id="sourcesProcessed">0</p>
                    <p class="text-sm text-gray-500"><span id="successRate">100</span>% success rate</p>
                </div>
                <div class="data-card bg-white p-6 rounded-lg shadow-sm">
                    <div class="flex items-center mb-3">
                        <div class="p-2 rounded-full bg-green-100 text-green-600 mr-3">
                            <i class="fas fa-database"></i>
                        </div>
                        <h3 class="text-lg font-medium">Data Extracted</h3>
                    </div>
                    <p class="text-3xl font-bold mb-2" id="totalDataPoints">0</p>
                    <p class="text-sm text-gray-500"><span id="uniqueData">0</span> unique records</p>
                </div>
                <div class="data-card bg-white p-6 rounded-lg shadow-sm">
                    <div class="flex items-center mb-3">
                        <div class="p-2 rounded-full bg-purple-100 text-purple-600 mr-3">
                            <i class="fas fa-map-marker-alt"></i>
                        </div>
                        <h3 class="text-lg font-medium">Area Code Matches</h3>
                    </div>
                    <p class="text-3xl font-bold mb-2" id="areaCodeMatches">0</p>
                    <p class="text-sm text-gray-500"><span id="relatedMatches">0</span> related matches</p>
                </div>
            </div>
            
            <!-- Data Tabs -->
            <div class="bg-white rounded-xl shadow-md overflow-hidden mb-8">
                <div class="border-b border-gray-200">
                    <nav class="-mb-px flex">
                        <button data-tab="contacts" class="tab-active whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm">Contacts</button>
                        <button data-tab="addresses" class="whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">Addresses</button>
                        <button data-tab="phones" class="whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">Phone Numbers</button>
                        <button data-tab="links" class="whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">Links</button>
                        <button data-tab="media" class="whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">Media</button>
                        <button data-tab="errors" class="whitespace-nowrap py-4 px-4 border-b-2 font-medium text-sm border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300">Errors</button>
                    </nav>
                </div>
                
                <!-- Contacts Tab -->
                <div id="contactsTab" class="p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Extracted Contacts</h3>
                        <div class="relative">
                            <input type="text" placeholder="Filter contacts..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="contactFilter">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fas fa-search text-gray-400"></i>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Title</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Phone</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                </tr>
                            </thead>
                            <tbody id="contactsTable" class="bg-white divide-y divide-gray-200">
                                <!-- Contacts will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="contactsEmpty" class="text-center py-12">
                        <i class="fas fa-user-slash text-4xl text-gray-300 mb-3"></i>
                        <p class="text-gray-500">No contacts found matching your criteria</p>
                    </div>
                </div>
                
                <!-- Addresses Tab -->
                <div id="addressesTab" class="p-6 hidden">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Extracted Addresses</h3>
                        <div class="flex space-x-2">
                            <button id="mapViewBtn" class="px-3 py-1 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">
                                <i class="fas fa-map mr-1"></i>Map View
                            </button>
                            <div class="relative">
                                <input type="text" placeholder="Filter addresses..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="addressFilter">
                                <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                    <i class="fas fa-search text-gray-400"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Address</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Coordinates</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                </tr>
                            </thead>
                            <tbody id="addressesTable" class="bg-white divide-y divide-gray-200">
                                <!-- Addresses will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="addressesEmpty" class="text-center py-12 hidden">
                        <i class="fas fa-map-marker-alt text-4xl text-gray-300 mb-3"></i>
                        <p class="text-gray-500">No addresses found matching your criteria</p>
                    </div>
                </div>
                
                <!-- Phone Numbers Tab -->
                <div id="phonesTab" class="p-6 hidden">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Extracted Phone Numbers</h3>
                        <div class="relative">
                            <input type="text" placeholder="Filter numbers..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="phoneFilter">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fas fa-search text-gray-400"></i>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Number</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Context</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                </tr>
                            </thead>
                            <tbody id="phonesTable" class="bg-white divide-y divide-gray-200">
                                <!-- Phone numbers will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="phonesEmpty" class="text-center py-12 hidden">
                        <i class="fas fa-phone-slash text-4xl text-gray-300 mb-3"></i>
                        <p class="text-gray-500">No phone numbers found matching your criteria</p>
                    </div>
                </div>
                
                <!-- Links Tab -->
                <div id="linksTab" class="p-6 hidden">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Extracted Links</h3>
                        <div class="relative">
                            <input type="text" placeholder="Filter links..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="linkFilter">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fas fa-search text-gray-400"></i>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">URL</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Anchor Text</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Domain</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                </tr>
                            </thead>
                            <tbody id="linksTable" class="bg-white divide-y divide-gray-200">
                                <!-- Links will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="linksEmpty" class="text-center py-12 hidden">
                        <i class="fas fa-unlink text-4xl text-gray-300 mb-3"></i>
                        <p class="text-gray-500">No links found matching your criteria</p>
                    </div>
                </div>
                
                <!-- Media Tab -->
                <div id="mediaTab" class="p-6 hidden">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Extracted Media</h3>
                        <div class="relative">
                            <input type="text" placeholder="Filter media..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="mediaFilter">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fas fa-search text-gray-400"></i>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">URL</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Dimensions</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Source</th>
                                </tr>
                            </thead>
                            <tbody id="mediaTable" class="bg-white divide-y divide-gray-200">
                                <!-- Media will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="mediaEmpty" class="text-center py-12 hidden">
                        <i class="fas fa-image text-4xl text-gray-300 mb-3"></i>
                        <p class="text-gray-500">No media found matching your criteria</p>
                    </div>
                </div>
                
                <!-- Errors Tab -->
                <div id="errorsTab" class="p-6 hidden">
                    <div class="flex justify-between items-center mb-4">
                        <h3 class="text-lg font-medium">Processing Errors</h3>
                        <div class="relative">
                            <input type="text" placeholder="Filter errors..." class="pl-8 pr-4 py-2 border border-gray-300 rounded-md text-sm focus:ring-indigo-500 focus:border-indigo-500" id="errorFilter">
                            <div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
                                <i class="fas fa-search text-gray-400"></i>
                            </div>
                        </div>
                    </div>
                    <div class="overflow-x-auto">
                        <table class="min-w-full divide-y divide-gray-200">
                            <thead class="bg-gray-50">
                                <tr>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">URL</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Error Type</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Message</th>
                                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Timestamp</th>
                                </tr>
                            </thead>
                            <tbody id="errorsTable" class="bg-white divide-y divide-gray-200">
                                <!-- Errors will be inserted here -->
                            </tbody>
                        </table>
                    </div>
                    <div id="errorsEmpty" class="text-center py-12 hidden">
                        <i class="fas fa-check-circle text-4xl text-green-300 mb-3"></i>
                        <p class="text-gray-500">No errors encountered during processing</p>
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-50 border-t border-gray-200 mt-12">
        <div class="container mx-auto px-4 py-8">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <p class="text-sm text-gray-500">&copy; <span id="currentYear"></span> Legal WebScraper Pro. All rights reserved.</p>
                    <p class="text-xs text-gray-400 mt-1">This tool complies with ethical web scraping guidelines and respects robots.txt</p>
                </div>
                <div class="flex space-x-4">
                    <a href="#" class="text-sm text-gray-500 hover:text-gray-700">Terms</a>
                    <a href="#" class="text-sm text-gray-500 hover:text-gray-700">Privacy</a>
                    <a href="#" class="text-sm text-gray-500 hover:text-gray-700">Contact</a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Set current year
        document.getElementById('currentYear').textContent = new Date().getFullYear();

        // Tab switching functionality
        const tabs = {
            manualTab: document.getElementById('manualTab'),
            fileTab: document.getElementById('fileTab'),
            aggregatorTab: document.getElementById('aggregatorTab'),
            manualContent: document.getElementById('manualContent'),
            fileContent: document.getElementById('fileContent'),
            aggregatorContent: document.getElementById('aggregatorContent')
        };

        tabs.manualTab.addEventListener('click', () => switchTab('manual'));
        tabs.fileTab.addEventListener('click', () => switchTab('file'));
        tabs.aggregatorTab.addEventListener('click', () => switchTab('aggregator'));

        function switchTab(tab) {
            // Reset all tabs
            tabs.manualTab.classList.remove('tab-active');
            tabs.manualTab.classList.add('text-gray-500', 'hover:text-gray-700');
            tabs.fileTab.classList.remove('tab-active');
            tabs.fileTab.classList.add('text-gray-500', 'hover:text-gray-700');
            tabs.aggregatorTab.classList.remove('tab-active');
            tabs.aggregatorTab.classList.add('text-gray-500', 'hover:text-gray-700');
            
            tabs.manualContent.classList.add('hidden');
            tabs.fileContent.classList.add('hidden');
            tabs.aggregatorContent.classList.add('hidden');

            // Activate selected tab
            if (tab === 'manual') {
                tabs.manualTab.classList.add('tab-active');
                tabs.manualTab.classList.remove('text-gray-500', 'hover:text-gray-700');
                tabs.manualContent.classList.remove('hidden');
            } else if (tab === 'file') {
                tabs.fileTab.classList.add('tab-active');
                tabs.fileTab.classList.remove('text-gray-500', 'hover:text-gray-700');
                tabs.fileContent.classList.remove('hidden');
            } else if (tab === 'aggregator') {
                tabs.aggregatorTab.classList.add('tab-active');
                tabs.aggregatorTab.classList.remove('text-gray-500', 'hover:text-gray-700');
                tabs.aggregatorContent.classList.remove('hidden');
            }
        }

        // File upload handling
        const dropZone = document.getElementById('dropZone');
        const fileInput = document.getElementById('fileInput');
        const fileInfo = document.getElementById('fileInfo');
        const fileName = document.getElementById('fileName');
        const fileSize = document.getElementById('fileSize');
        const fileType = document.getElementById('fileType');

        ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
            dropZone.addEventListener(eventName, preventDefaults, false);
        });

        function preventDefaults(e) {
            e.preventDefault();
            e.stopPropagation();
        }

        ['dragenter', 'dragover'].forEach(eventName => {
            dropZone.addEventListener(eventName, highlight, false);
        });

        ['dragleave', 'drop'].forEach(eventName => {
            dropZone.addEventListener(eventName, unhighlight, false);
        });

        function highlight() {
            dropZone.classList.add('dragover');
        }

        function unhighlight() {
            dropZone.classList.remove('dragover');
        }

        dropZone.addEventListener('drop', handleDrop, false);

        function handleDrop(e) {
            const dt = e.dataTransfer;
            const files = dt.files;
            handleFiles(files);
        }

        fileInput.addEventListener('change', function() {
            handleFiles(this.files);
        });

        function handleFiles(files) {
            if (files.length) {
                const file = files[0];
                fileName.textContent = file.name;
                fileSize.textContent = formatFileSize(file.size);
                fileType.textContent = file.type || file.name.split('.').pop();
                fileInfo.classList.remove('hidden');
            }
        }

        function formatFileSize(bytes) {
            if (bytes === 0) return '0 Bytes';
            const k = 1024;
            const sizes = ['Bytes', 'KB', 'MB', 'GB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));
            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }

        // Advanced options toggle
        const toggleAdvancedBtn = document.getElementById('toggleAdvancedBtn');
        const advancedOptions = document.getElementById('advancedOptions');
        
        toggleAdvancedBtn.addEventListener('click', function() {
            if (advancedOptions.classList.contains('hidden')) {
                advancedOptions.classList.remove('hidden');
                toggleAdvancedBtn.textContent = 'Hide';
            } else {
                advancedOptions.classList.add('hidden');
                toggleAdvancedBtn.textContent = 'Show';
            }
        });

        // Request delay slider
        const requestDelay = document.getElementById('requestDelay');
        const delayValue = document.getElementById('delayValue');
        
        requestDelay.addEventListener('input', function() {
            delayValue.textContent = this.value + 's';
        });

        // User agent selection
        const userAgent = document.getElementById('userAgent');
        const customUserAgent = document.getElementById('customUserAgent');
        
        userAgent.addEventListener('change', function() {
            if (this.value === 'custom') {
                customUserAgent.classList.remove('hidden');
            } else {
                customUserAgent.classList.add('hidden');
            }
        });

        // Database select all toggle
        const toggleDbBtn = document.getElementById('toggleDbBtn');
        const dbCheckboxes = [
            document.getElementById('censusCheck'),
            document.getElementById('fccCheck'),
            document.getElementById('uspsCheck'),
            document.getElementById('dunsCheck')
        ];
        
        let allSelected = true;
        
        toggleDbBtn.addEventListener('click', function() {
            allSelected = !allSelected;
            dbCheckboxes.forEach(checkbox => {
                checkbox.checked = allSelected;
            });
            toggleDbBtn.textContent = allSelected ? 'Deselect All' : 'Select All';
        });

        // Add sample URLs
        const addSampleBtn = document.getElementById('addSampleBtn');
        const urlInput = document.getElementById('urlInput');
        
        addSampleBtn.addEventListener('click', function() {
            const sampleUrls = [
                'https://www.census.gov/',
                'https://www.fcc.gov/',
                'https://tools.usps.com/zip-code-lookup.htm',
                'https://www.usa.gov/',
                'https://www.data.gov/'
            ];
            urlInput.value = sampleUrls.join('\n');
        });

        // Clear form
        const clearBtn = document.getElementById('clearBtn');
        
        clearBtn.addEventListener('click', function() {
            document.getElementById('areaCode').value = '';
            urlInput.value = '';
            fileInput.value = '';
            fileInfo.classList.add('hidden');
            document.getElementById('searchTopic').value = '';
            document.getElementById('resultLimit').value = '20';
            document.getElementById('includeGovCheck').checked = true;
            document.getElementById('includeEduCheck').checked = true;
            dbCheckboxes.forEach(checkbox => {
                checkbox.checked = true;
            });
            toggleDbBtn.textContent = 'Deselect All';
            allSelected = true;
            requestDelay.value = '3';
            delayValue.textContent = '3s';
            document.getElementById('respectRobots').checked = true;
            document.getElementById('jsRendering').checked = false;
            userAgent.value = 'default';
            customUserAgent.classList.add('hidden');
            customUserAgent.value = '';
        });

        // Start scraping
        const startBtn = document.getElementById('startBtn');
        const progressSection = document.getElementById('progressSection');
        const resultsSection = document.getElementById('resultsSection');
        
        startBtn.addEventListener('click', function() {
            const areaCode = document.getElementById('areaCode').value.trim();
            
            // Validate area code
            if (!areaCode || !/^\d{3,5}$/.test(areaCode)) {
                document.getElementById('areaCodeError').classList.remove('hidden');
                return;
            } else {
                document.getElementById('areaCodeError').classList.add('hidden');
            }
            
            // Show progress section
            progressSection.classList.remove('hidden');
            document.getElementById('resultsSection').classList.add('hidden');
            
            // Start the scraping simulation
            simulateScraping();
        });

        // Stop scraping
        const stopBtn = document.getElementById('stopBtn');
        
        stopBtn.addEventListener('click', function() {
            // In a real implementation, this would stop any ongoing requests
            document.getElementById('statusText').textContent = 'Stopped by user';
            document.getElementById('progressBar').style.width = '0%';
            document.getElementById('progressText').textContent = '0%';
            
            // Add to activity log
            const logEntry = document.createElement('div');
            logEntry.className = 'text-red-500';
            logEntry.innerHTML = '<i class="fas fa-stop-circle mr-1"></i> Process stopped by user';
            document.getElementById('activityLog').appendChild(logEntry);
        });

        // Results tabs
        const resultTabs = document.querySelectorAll('[data-tab]');
        
        resultTabs.forEach(tab => {
            tab.addEventListener('click', function() {
                // Remove active class from all tabs
                resultTabs.forEach(t => {
                    t.classList.remove('tab-active');
                    t.classList.add('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300');
                });
                
                // Add active class to clicked tab
                this.classList.add('tab-active');
                this.classList.remove('border-transparent', 'text-gray-500', 'hover:text-gray-700', 'hover:border-gray-300');
                
                // Hide all tab contents
                document.getElementById('contactsTab').classList.add('hidden');
                document.getElementById('addressesTab').classList.add('hidden');
                document.getElementById('phonesTab').classList.add('hidden');
                document.getElementById('linksTab').classList.add('hidden');
                document.getElementById('mediaTab').classList.add('hidden');
                document.getElementById('errorsTab').classList.add('hidden');
                
                // Show selected tab content
                const tabName = this.getAttribute('data-tab');
                document.getElementById(`${tabName}Tab`).classList.remove('hidden');
            });
        });

        // Export buttons
        document.getElementById('exportCsvBtn').addEventListener('click', function() {
            alert('CSV export functionality would be implemented here');
        });
        
        document.getElementById('exportJsonBtn').addEventListener('click', function() {
            alert('JSON export functionality would be implemented here');
        });
        
        document.getElementById('exportPdfBtn').addEventListener('click', function() {
            alert('PDF export functionality would be implemented here');
        });

        // Map view button
        document.getElementById('mapViewBtn').addEventListener('click', function() {
            alert('Map view functionality would be implemented here');
        });

        // Filter inputs
        const filterInputs = [
            { id: 'contactFilter', table: 'contactsTable', empty: 'contactsEmpty' },
            { id: 'addressFilter', table: 'addressesTable', empty: 'addressesEmpty' },
            { id: 'phoneFilter', table: 'phonesTable', empty: 'phonesEmpty' },
            { id: 'linkFilter', table: 'linksTable', empty: 'linksEmpty' },
            { id: 'mediaFilter', table: 'mediaTable', empty: 'mediaEmpty' },
            { id: 'errorFilter', table: 'errorsTable', empty: 'errorsEmpty' }
        ];
        
        filterInputs.forEach(filter => {
            const input = document.getElementById(filter.id);
            input.addEventListener('input', function() {
                const value = this.value.toLowerCase();
                const rows = document.getElementById(filter.table).getElementsByTagName('tr');
                let visibleCount = 0;
                
                for (let row of rows) {
                    const text = row.textContent.toLowerCase();
                    if (text.includes(value)) {
                        row.style.display = '';
                        visibleCount++;
                    } else {
                        row.style.display = 'none';
                    }
                }
                
                if (visibleCount === 0) {
                    document.getElementById(filter.empty).classList.remove('hidden');
                } else {
                    document.getElementById(filter.empty).classList.add('hidden');
                }
            });
        });

        // Simulate scraping process
        function simulateScraping() {
            const statusText = document.getElementById('statusText');
            const progressBar = document.getElementById('progressBar');
            const progressText = document.getElementById('progressText');
            const processedCount = document.getElementById('processedCount');
            const totalCount = document.getElementById('totalCount');
            const dataPoints = document.getElementById('dataPoints');
            const errorCount = document.getElementById('errorCount');
            const timeElapsed = document.getElementById('timeElapsed');
            const activityLog = document.getElementById('activityLog');
            
            let progress = 0;
            let processed = 0;
            const total = 24;
            let dataPointsCount = 0;
            let errors = 0;
            let seconds = 0;
            
            totalCount.textContent = total;
            
            // Start timer
            const timer = setInterval(() => {
                seconds++;
                const minutes = Math.floor(seconds / 60);
                const remainingSeconds = seconds % 60;
                timeElapsed.textContent = `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
            }, 1000);
            
            // Simulate progress
            const interval = setInterval(() => {
                if (progress >= 100) {
                    clearInterval(interval);
                    clearInterval(timer);
                    statusText.textContent = 'Completed';
                    
                    // Show results section
                    progressSection.classList.add('hidden');
                    resultsSection.classList.remove('hidden');
                    document.getElementById('exportBtn').classList.remove('hidden');
                    
                    // Populate results
                    populateResults();
                    return;
                }
                
                progress += Math.floor(Math.random() * 5) + 1;
                if (progress > 100) progress = 100;
                
                processed += Math.floor(Math.random() * 2) + 1;
                if (processed > total) processed = total;
                
                dataPointsCount += Math.floor(Math.random() * 3) + 1;
                
                // Random chance of error
                if (Math.random() < 0.1) {
                    errors++;
                    const logEntry = document.createElement('div');
                    logEntry.className = 'text-red-500';
                    logEntry.innerHTML = `<i class="fas fa-exclamation-circle mr-1"></i> Error processing URL ${processed}/${total}: Connection timeout`;
                    activityLog.appendChild(logEntry);
                    activityLog.scrollTop = activityLog.scrollHeight;
                } else {
                    const logEntry = document.createElement('div');
                    logEntry.className = 'text-green-600';
                    logEntry.innerHTML = `<i class="fas fa-check-circle mr-1"></i> Successfully processed URL ${processed}/${total}`;
                    activityLog.appendChild(logEntry);
                    activityLog.scrollTop = activityLog.scrollHeight;
                }
                
                // Update status randomly
                const statuses = [
                    'Scraping websites...',
                    'Processing national databases...',
                    'Extracting contact information...',
                    'Identifying phone numbers...',
                    'Locating addresses...',
                    'Analyzing media files...',
                    'Compiling results...'
                ];
                
                if (Math.random() < 0.2) {
                    statusText.textContent = statuses[Math.floor(Math.random() * statuses.length)];
                }
                
                // Update UI
                progressBar.style.width = `${progress}%`;
                progressText.textContent = `${progress}%`;
                processedCount.textContent = processed;
                dataPoints.textContent = dataPointsCount;
                errorCount.textContent = errors;
            }, 500);
        }

        // Populate results with sample data
        function populateResults() {
            // Update summary cards
            document.getElementById('sourcesProcessed').textContent = '24';
            document.getElementById('successRate').textContent = '92';
            document.getElementById('totalDataPoints').textContent = '137';
            document.getElementById('uniqueData').textContent = '89';
            document.getElementById('areaCodeMatches').textContent = '18';
            document.getElementById('relatedMatches').textContent = '42';
            
            // Sample contacts
            const sampleContacts = [
                { name: "John Smith", title: "Director of Communications", email: "john.smith@example.gov", phone: "(202) 555-0123", source: "https://www.example.gov/about" },
                { name: "Sarah Johnson", title: "Public Records Officer", email: "sjohnson@cityhall.org", phone: "(202) 555-0456", source: "https://cityhall.org/contact" },
                { name: "Robert Chen", title: "IT Administrator", email: "r.chen@university.edu", phone: "(617) 555-0789", source: "https://university.edu/staff" },
                { name: "Maria Garcia", title: "Customer Service Manager", email: "maria.garcia@business.com", phone: "(800) 555-0987", source: "https://business.com/team" },
                { name: "David Wilson", title: "Legal Counsel", email: "dwilson@lawfirm.org", phone: "(212) 555-0321", source: "https://lawfirm.org/attorneys" }
            ];
            
            const contactsTable = document.getElementById('contactsTable');
            sampleContacts.forEach(contact => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap">${contact.name}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${contact.title}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="mailto:${contact.email}" class="text-blue-600 hover:text-blue-800">${contact.email}</a></td>
                    <td class="px-6 py-4 whitespace-nowrap">${contact.phone}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="${contact.source}" target="_blank" class="text-blue-600 hover:text-blue-800">View source</a></td>
                `;
                contactsTable.appendChild(row);
            });
            
            // Sample addresses
            const sampleAddresses = [
                { address: "1600 Pennsylvania Ave NW<br>Washington, DC 20500", type: "Government", coordinates: "38.8977° N, 77.0365° W", source: "https://www.example.gov/contact" },
                { address: "1 City Hall Plaza<br>Boston, MA 02201", type: "Municipal", coordinates: "42.3601° N, 71.0589° W", source: "https://cityhall.org/locations" },
                { address: "350 5th Ave<br>New York, NY 10118", type: "Business", coordinates: "40.7484° N, 73.9857° W", source: "https://business.com/locations" },
                { address: "1 Harvard Yard<br>Cambridge, MA 02138", type: "Educational", coordinates: "42.3744° N, 71.1169° W", source: "https://university.edu/campus" }
            ];
            
            const addressesTable = document.getElementById('addressesTable');
            sampleAddresses.forEach(address => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4">${address.address}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${address.type}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${address.coordinates}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="${address.source}" target="_blank" class="text-blue-600 hover:text-blue-800">View source</a></td>
                `;
                addressesTable.appendChild(row);
            });
            
            // Sample phone numbers
            const samplePhones = [
                { number: "(202) 555-0123", type: "Main Office", context: "Government contact page", source: "https://www.example.gov/contact" },
                { number: "(800) 555-1234", type: "Customer Service", context: "Business homepage footer", source: "https://business.com" },
                { number: "(617) 555-9876", type: "Admissions", context: "University contact page", source: "https://university.edu/contact" },
                { number: "(212) 555-4567", type: "Legal Department", context: "Law firm staff directory", source: "https://lawfirm.org/staff" }
            ];
            
            const phonesTable = document.getElementById('phonesTable');
            samplePhones.forEach(phone => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap">${phone.number}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${phone.type}</td>
                    <td class="px-6 py-4">${phone.context}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="${phone.source}" target="_blank" class="text-blue-600 hover:text-blue-800">View source</a></td>
                `;
                phonesTable.appendChild(row);
            });
            
            // Sample links
            const sampleLinks = [
                { url: "https://www.example.gov/privacy", anchor: "Privacy Policy", domain: "example.gov", source: "https://www.example.gov" },
                { url: "https://business.com/terms", anchor: "Terms of Service", domain: "business.com", source: "https://business.com" },
                { url: "https://university.edu/admissions", anchor: "Admissions Information", domain: "university.edu", source: "https://university.edu" },
                { url: "https://lawfirm.org/contact", anchor: "Contact Our Team", domain: "lawfirm.org", source: "https://lawfirm.org" }
            ];
            
            const linksTable = document.getElementById('linksTable');
            sampleLinks.forEach(link => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4"><a href="${link.url}" target="_blank" class="text-blue-600 hover:text-blue-800">${link.url}</a></td>
                    <td class="px-6 py-4">${link.anchor}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${link.domain}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="${link.source}" target="_blank" class="text-blue-600 hover:text-blue-800">View source</a></td>
                `;
                linksTable.appendChild(row);
            });
            
            // Sample media
            const sampleMedia = [
                { type: "JPEG Image", url: "https://www.example.gov/images/logo.jpg", dimensions: "300×150", source: "https://www.example.gov" },
                { type: "PDF Document", url: "https://business.com/docs/annual-report.pdf", dimensions: "24 pages", source: "https://business.com" },
                { type: "PNG Image", url: "https://university.edu/images/campus.png", dimensions: "1200×800", source: "https://university.edu" },
                { type: "MP4 Video", url: "https://lawfirm.org/videos/welcome.mp4", dimensions: "1280×720", source: "https://lawfirm.org" }
            ];
            
            const mediaTable = document.getElementById('mediaTable');
            sampleMedia.forEach(media => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4 whitespace-nowrap">${media.type}</td>
                    <td class="px-6 py-4"><a href="${media.url}" target="_blank" class="text-blue-600 hover:text-blue-800">${media.url}</a></td>
                    <td class="px-6 py-4 whitespace-nowrap">${media.dimensions}</td>
                    <td class="px-6 py-4 whitespace-nowrap"><a href="${media.source}" target="_blank" class="text-blue-600 hover:text-blue-800">View source</a></td>
                `;
                mediaTable.appendChild(row);
            });
            
            // Sample errors
            const sampleErrors = [
                { url: "https://blocked-site.org", error: "403 Forbidden", message: "Access denied by robots.txt", timestamp: "00:01:23" },
                { url: "https://timeout-example.com", error: "Timeout", message: "Server did not respond in time", timestamp: "00:02:45" }
            ];
            
            const errorsTable = document.getElementById('errorsTable');
            sampleErrors.forEach(error => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td class="px-6 py-4"><a href="${error.url}" target="_blank" class="text-blue-600 hover:text-blue-800">${error.url}</a></td>
                    <td class="px-6 py-4 whitespace-nowrap">${error.error}</td>
                    <td class="px-6 py-4">${error.message}</td>
                    <td class="px-6 py-4 whitespace-nowrap">${error.timestamp}</td>
                `;
                errorsTable.appendChild(row);
            });
        }
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=MarcRyan/area-code-focused-data-extraction-tool" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>